Esempio n. 1
0
        public async Task D_A_UseService_ServiceSucceeds_Succeeds()
        {
            var service = new Mock<IService>();
            var sut = new Sut
            {
                Service = service.Object
            };

            await sut.UseServiceAsync();
        }
Esempio n. 2
0
        public async Task C_E_NSubstituteWorksGreatOutOfTheBox()
        {
            var service = Substitute.For<IService>();
            var sut = new Sut
            {
                Service = service
            };

            await sut.UseServiceAsync();
        }
Esempio n. 3
0
        public async Task C_D_FakeItEasyWorksGreatOutOfTheBox()
        {
            var service = A.Fake<IService>();
            var sut = new Sut
            {
                Service = service
            };

            await sut.UseServiceAsync();
        }
Esempio n. 4
0
        public async Task C_C_MoqWorksGreatOutOfTheBox()
        {
            var service = new Mock<IService>();
            var sut = new Sut
            {
                Service = service.Object
            };

            await sut.UseServiceAsync();
        }
Esempio n. 5
0
        public async Task C_A_MSTestDefaultBehaviorIsNotGoodForAsyncStubs()
        {
            var service = new SystemUnderTest.Fakes.StubIService();
            var sut = new Sut
            {
                Service = service
            };

            await sut.UseServiceAsync();
        }
Esempio n. 6
0
        public async Task C_B_ButMSTestDefaultStubBehaviorCanBeChanged()
        {
            var service = new SystemUnderTest.Fakes.StubIService
            {
                InstanceBehavior = new AsyncAwareDefaultValueStubBehavior()
            };
            var sut = new Sut
            {
                Service = service
            };

            await sut.UseServiceAsync();
        }
Esempio n. 7
0
        public async Task D_B_UseService_ServiceFails_PropagatesException()
        {
            var service = new Mock<IService>();
            var exception = new Exception("Test failure.");
            service.Setup(x => x.DoSomethingAsync()).Returns(Task.FromException(exception));
            var sut = new Sut
            {
                Service = service.Object
            };

            var resultException = await AsyncAssert.ThrowsAsync<Exception>(async () => await sut.UseServiceAsync());

            Assert.AreSame(exception, resultException);
        }