PageRenderTime 40ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Ninject.Tests/Unit/NamedAttributeTests.cs

https://github.com/developingchris/ninject
C# | 37 lines | 33 code | 4 blank | 0 comment | 0 complexity | 3a8e872ae77498cf8558f0f473d71965 MD5 | raw file
  1. using System;
  2. using Moq;
  3. using Ninject.Planning.Bindings;
  4. using Xunit;
  5. using Xunit.Should;
  6. namespace Ninject.Tests.Unit.NamedAttributeTests
  7. {
  8. public class NamedAttributeContext
  9. {
  10. protected readonly NamedAttribute attribute;
  11. protected readonly Mock<IBindingMetadata> metadataMock;
  12. public NamedAttributeContext()
  13. {
  14. attribute = new NamedAttribute("foo");
  15. metadataMock = new Mock<IBindingMetadata>();
  16. }
  17. }
  18. public class WhenMatchesIsCalled : NamedAttributeContext
  19. {
  20. [Fact]
  21. public void ReturnsTrueIfTheNameMatches()
  22. {
  23. metadataMock.SetupGet(x => x.Name).Returns("foo");
  24. attribute.Matches(metadataMock.Object).ShouldBeTrue();
  25. }
  26. [Fact]
  27. public void ReturnsFalseIfTheNameDoesNotMatch()
  28. {
  29. metadataMock.SetupGet(x => x.Name).Returns("bar");
  30. attribute.Matches(metadataMock.Object).ShouldBeFalse();
  31. }
  32. }
  33. }