Esempio n. 1
0
        public void GetHardware_ShouldReturnHardwareWithSameID()
        {
            var context = new TestHardwareAppContext();

            context.Hardwares.Add(GetDemoHardware());

            var controller = new HardwareController(context);
            var result     = controller.GetHardware(3) as OkNegotiatedContentResult <Hardware>;

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Content.Id);
        }
Esempio n. 2
0
        public void DeleteHardware_ShouldReturnOK()
        {
            var context = new TestHardwareAppContext();
            var item    = GetDemoHardware();

            context.Hardwares.Add(item);

            var controller = new HardwareController(context);
            var result     = controller.DeleteHardware(3) as OkNegotiatedContentResult <Hardware>;

            Assert.IsNotNull(result);
            Assert.AreEqual(item.Id, result.Content.Id);
        }
Esempio n. 3
0
        public void GetHardwares_ShouldReturnAllHardwares()
        {
            var context = new TestHardwareAppContext();

            context.Hardwares.Add(new Hardware {
                Id = 1, Description = "Demo1", PurchasePrice = 20, SerialNumber = "ABC123", Type = "Printer"
            });
            context.Hardwares.Add(new Hardware {
                Id = 2, Description = "Demo2", PurchasePrice = 30, SerialNumber = "ABC123", Type = "Screen"
            });
            context.Hardwares.Add(new Hardware {
                Id = 3, Description = "Demo3", PurchasePrice = 40, SerialNumber = "ABC123", Type = "Keyboard"
            });

            var controller = new HardwareController(context);
            var result     = controller.GetHardware() as TestHardwareDbSet;

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Local.Count);
        }