예제 #1
0
        public void UserService_Delete_Throws_When_Id_Empty()
        {
            CollectionMock
            .Setup(s => s.DeleteOne(It.IsAny <FilterDefinition <User> >(), CancellationToken.None))
            .Returns(new DeleteResult.Acknowledged(1));

            var target = CreateTarget(CollectionMock);

            Assert.Throws <ArgumentException>(() => target.Delete(""));
        }
예제 #2
0
        public void UserService_Delete_Is_Silent_When_Id_Not_Found()
        {
            var expectedId = "filip";

            CollectionMock
            .Setup(s => s.DeleteOne(It.IsAny <FilterDefinition <User> >(), CancellationToken.None))
            .Returns(new DeleteResult.Acknowledged(0));

            var target = CreateTarget(CollectionMock);

            Assert.False(target.Delete(expectedId));

            CollectionMock.Verify(s => s.DeleteOne(It.IsAny <FilterDefinition <User> >(), CancellationToken.None), Times.Once);
        }
예제 #3
0
        public void UserService_Delete()
        {
            var expectedId = "filip";

            CollectionMock
            .Setup(s => s.DeleteOne(It.IsAny <FilterDefinition <User> >(), CancellationToken.None))
            .Returns(new DeleteResult.Acknowledged(1));

            var target = CreateTarget(CollectionMock);

            target.Delete(expectedId);

            CollectionMock.Verify(s => s.DeleteOne(It.IsAny <FilterDefinition <User> >(), CancellationToken.None), Times.Once);
        }