Ejemplo n.º 1
0
        public void Update(ManufacturerViewModel model)
        {
            var manufacturerModel = new ManufacturerModel
            {
                Name = model.Name
            };

            manufacturerService.Update(manufacturerModel);
        }
Ejemplo n.º 2
0
        public async Task UpdateTest()
        {
            var fakeRepository      = Mock.Of <IManufacturerRepository>();
            var manufacturerService = new ManufacturerService(fakeRepository);

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

            var man = new Manufacturer()
            {
                Id = 1,
                //Name = "TestMan"
            };

            var e = Assert.Throws <ArgumentException>(() => manufacturerService.Update(man));

            Assert.Equal("Name cannot be null or empty", e.Message);
        }
Ejemplo n.º 4
0
        public void InsertManufacturerWithNameThatIsSoftDeletedTest()
        {
            TestManufacturer.IsDeleted = true;
            ManufacturerService.Update(TestManufacturer);

            var newManufacturer = new Manufacturer {
                ManufacturerName = TestManufacturerName
            };

            ManufacturerService.Upsert(newManufacturer, TestUserPrincipal);

            var foundManufacturers = ManufacturerService.Search(TestManufacturerName).ToList();

            Assert.AreEqual(1, foundManufacturers.Count);
            Assert.AreEqual(foundManufacturers.First().ManufacturerName, TestManufacturer.ManufacturerName);
            Assert.IsFalse(foundManufacturers.First().IsDeleted);
        }
        public void UpdateManufacturerEnsureRepositoryIsCalled()
        {
            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.Update(man)).Callback(() => isCalled = true).Returns(new Manufacturer()
            {
                Id     = 1,
                Name   = "TestMan",
                Drones = null
            });

            manufacturerService.Update(man);
            Assert.True(isCalled);
        }