Exemplo n.º 1
0
        public async Task TestCalculationWithDependenciesThrowsError()
        {
            var mockDep = Substitute.For <IDependency>();

            mockDep.When(x => x.AsyncExternalCall(Arg.Any <int>())).Do(y => { throw new System.Exception("no network"); });
            var sut = new NonDeterministic(mockDep);

            var result = await sut.CalculationWithDependencies(2, 8);
        }
Exemplo n.º 2
0
        public async Task TestCalculationWithDependencies()
        {
            var mockDep = Substitute.For <IDependency>();

            mockDep.AsyncExternalCall(Arg.Any <int>()).Returns(Task.FromResult(4));
            var sut = new NonDeterministic(mockDep);

            var result = await sut.CalculationWithDependencies(2, 8);

            await mockDep.Received().AsyncExternalCall(2);

            Assert.AreEqual <int>(12, result);
        }