예제 #1
0
        [ExpectedException(typeof (NullReferenceException))] // Assert 
        public async void DeleteUser_Fail_UserDoesNotExist_Test()
        {
            //Arrange
            var repositoryMock = new Mock<IRepository<StoredUser>>();
            const int toDeleteId = 0;
            repositoryMock.Setup(r => r.DeleteIfExists(toDeleteId)).Returns(Task.FromResult(false));
            var adapter = new UserAdapter(repositoryMock.Object);

            //Act
            await adapter.DeleteIfExists(toDeleteId);
        }
예제 #2
0
        public async void DeleteUser_Success_Test()
        {
            //Arrange
            var repositoryMock = new Mock<IRepository<StoredUser>>();
            const int toDeleteId = 0;
            repositoryMock.Setup(r => r.DeleteIfExists(toDeleteId)).Returns(Task.FromResult(true));
            var adapter = new UserAdapter(repositoryMock.Object);

            //Act
            var result = await adapter.DeleteIfExists(toDeleteId);

            //Assert
            Assert.IsTrue(result);
        }