Esempio n. 1
0
        public async Task DeleteTest()
        {
            var fakeRepository      = Mock.Of <IManufacturerRepository>();
            var manufacturerService = new ManufacturerService(fakeRepository);

            var manufacturer = new Manufacturer()
            {
                Name = "Dias", Address = "USA LA"
            };
            await manufacturerService.Delete(manufacturer);
        }
        public void DeleteManufacturerWithIdLowerThan1ThrowsException()
        {
            var manufacturerRepo = new Mock <IManufacturerRepository>();
            IManufacturerService manufacturerService = new ManufacturerService(manufacturerRepo.Object);

            var manufacturer = new Manufacturer()
            {
                Id   = 0,
                Name = "TestMan"
            };

            var e = Assert.Throws <ArgumentException>(() => manufacturerService.Delete(manufacturer.Id));

            Assert.Equal("The Id entered has to be at least 1", e.Message);
        }
        public void DeleteManufacturerEnsureRepositoryIsCalled()
        {
            var manufacturerRepo = new Mock <IManufacturerRepository>();
            IManufacturerService manufacturerService = new ManufacturerService(manufacturerRepo.Object);

            var isCalled = false;
            var man      = new Manufacturer()
            {
                Id     = 1,
                Name   = "TestMan",
                Drones = null
            };

            manufacturerRepo.Setup(x => x.Delete(man.Id)).Callback(() => isCalled = true).Returns(new Manufacturer()
            {
                Id     = 1,
                Name   = "TestMan",
                Drones = null
            });

            manufacturerService.Delete(man.Id);
            Assert.True(isCalled);
        }
Esempio n. 4
0
 public void Delete(int id)
 {
     manufacturerService.Delete(id);
 }