예제 #1
0
        public void SampleProvider_ExecuteWithDto_Succeeds(
            ISampleService sampleService,
            SampleDto dto,
            string returnValue)
        {
            A.CallTo(() => sampleService.CanExecute)
            .Returns(true);
            A.CallTo(() => sampleService.ExecuteWithDto(dto))
            .Returns(returnValue);

            var sampleProvider = new SampleProvider(sampleService);
            var actual         = sampleProvider.ExecuteSampleWithDto(dto);

            A.CallTo(() => sampleService.ExecuteWithDto(A <SampleDto> .Ignored))
            .MustHaveHappened(Repeated.Exactly.Once);
            Assert.Equal(returnValue, actual);
        }
예제 #2
0
        public void SampleProvider_ExecuteWithDto_CanExecute_Succeeds(
            bool canExecute,
            string returnValue,
            ISampleService sampleService,
            SampleDto dto)
        {
            // Arrange
            A.CallTo(() => sampleService.CanExecute)
            .Returns(canExecute);
            A.CallTo(() => sampleService.ExecuteWithDto(dto))
            .Returns(returnValue);
            var sampleProvider = new SampleProvider(sampleService);

            // Act
            var actual = sampleProvider.ExecuteSampleWithDto(dto);

            // Assert
            A.CallTo(() => sampleService.ExecuteWithDto(A <SampleDto> .Ignored))
            .MustHaveHappenedANumberOfTimesMatching(n => n == (canExecute ? 1 : 0));
            Assert.Equal(returnValue, actual);
        }
예제 #3
0
        public void SampleProvider_ExecuteWithDto_CanExecute_Succeeds(
            bool canExecute,
            string returnValue,
            ISampleService sampleService,
            SampleDto dto)
        {
            // Arrange
            A.CallTo(() => sampleService.CanExecute)
            .Returns(canExecute);
            A.CallTo(() => sampleService.ExecuteWithDto(dto))
            .Returns(returnValue);
            var sampleProvider = new SampleProvider(sampleService);

            // Act
            var actual = sampleProvider.ExecuteSampleWithDto(dto);

            // Assert
            A.CallTo(() => sampleService.ExecuteWithDto(A <SampleDto> .Ignored))
            .MustHaveHappened(
                canExecute
                    ? Repeated.Exactly.Once
                    : Repeated.Never);
            Assert.Equal(returnValue, actual);
        }