Esempio n. 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);
        }
Esempio n. 2
0
        public string ExecuteSampleWithDto(SampleDto value)
        {
            if (_sampleService.CanExecute)
            {
                return(_sampleService.ExecuteWithDto(value));
            }

            return(string.Empty);
        }
Esempio n. 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))
            .MustHaveHappenedANumberOfTimesMatching(n => n == (canExecute ? 1 : 0));
            Assert.Equal(returnValue, actual);
        }
Esempio n. 4
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);
        }