Esempio n. 1
0
        public async Task should_delete_service_when_input_valid()
        {
            var startTicks = DateTime.UtcNow.Ticks;

            var service = new Mongo.Infrastructure.Entities.Service()
            {
                Id        = Guid.NewGuid(),
                Active    = true,
                Name      = "lorem",
                Endpoints = Enumerable.Empty <Mongo.Infrastructure.Entities.ServiceEndpoint>()
            };
            var mockServicesRepo = RepositoryUtils.MockRepository(service);

            var mockDbContext = new Mock <IDbContext>();

            mockDbContext.Setup(db => db.Services).Returns(mockServicesRepo.Object);

            var validator = new NullValidator <DeleteService>();

            var sut = new DeleteServiceHandler(mockDbContext.Object, validator);

            await sut.Handle(new DeleteService(service.Id));

            mockServicesRepo.Verify(m => m.DeleteOneAsync(It.IsAny <Expression <Func <Mongo.Infrastructure.Entities.Service, bool> > >()), Times.Once());
        }
Esempio n. 2
0
        public async Task should_fail_when_command_null()
        {
            var mockDbContext = new Mock <IDbContext>();
            var mockValidator = new Mock <IValidator <DeleteService> >();

            var sut = new DeleteServiceHandler(mockDbContext.Object, mockValidator.Object);
            await Assert.ThrowsAsync <ArgumentNullException>(() => sut.Handle(null));
        }