public void ACallTo() { FakeContainer container = new FakeContainer(); A.CallTo(() => container.Locate<IBasicService>(null, null, null).TestMethod()).Returns(5); ImportConstructorService importConstructorService = container.Locate<ImportConstructorService>(); Assert.Equal(5, importConstructorService.TestMethod()); A.CallTo(() => container.Locate<IBasicService>(null, null, null).TestMethod()).MustHaveHappened(Repeated.Exactly.Once); }
public void ConfigureArrangeTest() { FakeContainer container = new FakeContainer(); container.Configure(c => c.Fake<IBasicService>(). Arrange(x => A.CallTo(() => x.TestMethod()).Returns(5)). AndSingleton()); ImportConstructorService importConstructorService = container.Locate<ImportConstructorService>(); Assert.Equal(5, importConstructorService.TestMethod()); A.CallTo(() => container.Locate<IBasicService>(null, null, null).TestMethod()).MustHaveHappened(Repeated.Exactly.Once); }
public void BasicFakeContainerTest() { FakeContainer container = new FakeContainer(); ImportConstructorService importConstructorService = container.Locate<ImportConstructorService>(); Assert.NotNull(importConstructorService); Assert.NotNull(importConstructorService.BasicService); }
public void ConfigureAssertTest() { FakeContainer container = new FakeContainer(); container.Configure(c => c.Fake<IBasicService>(). Arrange(x => A.CallTo(() => x.TestMethod()).Returns(5)). Assert(x => A.CallTo(() => x.TestMethod()).MustHaveHappened(Repeated.Exactly.Twice))); ImportConstructorService importConstructorService = container.Locate<ImportConstructorService>(); Assert.Equal(5, importConstructorService.TestMethod()); try { container.Assert(); throw new Exception("This should have thrown an exception from the assert"); } catch (ExpectationException) { // we are expecting this } }