Пример #1
0
        public void BugService_When_CloseBugIsCalledWithAEmptySpaceId_Then_ApplicationExceptionIsThrown()
        {
            var id = " ";

            var service = new BugService(_repository.Object);

            Assert.ThrowsAsync <ApplicationException>(() => service.CloseBug(id));
        }
Пример #2
0
        public void BugService_When_CloseBugIsCalledWithAnIdThatDoesntExist_Then_ApplicationExceptionIsThrown()
        {
            var id  = "123";
            Bug bug = null;

            _repository.Setup(_ => _.Find(id)).ReturnsAsync(bug);
            var service = new BugService(_repository.Object);

            Assert.ThrowsAsync <ApplicationException>(() => service.CloseBug(id));
        }
Пример #3
0
        public async void BugService_When_CloseBugIsCalledWithAnIdThatExistsAndUpdateBugIsCalledOnRepositoryButFails_Then_FalseIsReturned()
        {
            var id  = "123";
            var bug = new Bug {
                Id = "123", Title = "Test Title", Description = "Test description", ClosedOn = DateTime.MinValue, Status = Status.Opened
            };

            _repository.Setup(_ => _.Find(id)).ReturnsAsync(bug);
            _repository.Setup(_ => _.Update(bug)).ReturnsAsync(false);
            var service = new BugService(_repository.Object);

            var result = await service.CloseBug(id);

            Assert.False(result);
        }
Пример #4
0
        public async void BugService_When_CloseBugIsCalledWithAnIdThatExistsAndUpdateBugIsCalledOnRepositorySuccessfullyThen_TrueIsReturned()
        {
            var id  = "123";
            var bug = new Bug {
                Id = "123", Title = "Test Title", Description = "Test description", ClosedOn = DateTime.MinValue, Status = Status.Opened
            };

            _repository.Setup(_ => _.Find(id)).ReturnsAsync(bug);
            _repository.Setup(_ => _.Update(bug)).ReturnsAsync(true);
            var service = new BugService(_repository.Object);

            var result = await service.CloseBug(id);

            Assert.Equal(Status.Closed, bug.Status);
            Assert.NotEqual(DateTime.MinValue, bug.ClosedOn);
            Assert.True(result);
        }