public void EquipmentTypeManager_DeleteEquipmentType_Equipment_Values()
        {
            var saveTask = Task <EquipmentType> .Factory.StartNew(() => { return(new EquipmentType()); });

            var equipmentSave = Task <Equipment> .Factory.StartNew(() => { return(new Equipment()); });

            EquipmentTypeAccessor.Arrange(x => x.GetEquipmentType(Arg.IsAny <long>()))
            .Returns(Task.FromResult(new EquipmentType()))
            .OccursOnce();
            EquipmentTypeAccessor.Arrange(x => x.SaveEquipmentType(Arg.IsAny <EquipmentType>()))
            .Returns(saveTask)
            .OccursOnce();
            EquipmentAccessor.Arrange(x => x.GetEquipmentByType(Arg.IsAny <long>()))
            .Returns(Task.FromResult(new List <Equipment> {
                new Equipment {
                    EquipmentTypeId = 5
                }, new Equipment()
            }.AsEnumerable()))
            .OccursOnce();
            EquipmentAccessor.Arrange(x => x.SaveEquipment(Arg.Matches <Equipment>(y => y.EquipmentTypeId == 1)))
            .Returns(equipmentSave)
            .Occurs(2);



            var res = manager.DeleteEquipmentType(5).Result;

            saveTask.Wait();
            equipmentSave.Wait();
            EquipmentTypeAccessor.Assert();
            EquipmentAccessor.Assert();
            Assert.IsNotNull(res);
            Assert.IsTrue(res);
        }
Esempio n. 2
0
        public void EquipmentManager_SaveEquipment()
        {
            EquipmentAccessor.Arrange(x => x.SaveEquipment(Arg.IsAny <Equipment>()))
            .Returns(Task.FromResult(new Equipment()))
            .OccursOnce();

            var res = manager.SaveEquipment(new Equipment()).Result;

            Assert.IsNotNull(res);
            EquipmentAccessor.Assert();
        }
Esempio n. 3
0
        public void EquipmentManager_GetEquipmentSchedule()
        {
            EquipmentAccessor.Arrange(x => x.GetEquipmentSchedule(Arg.IsAny <long>()))
            .Returns(Task.FromResult(Enumerable.Empty <EquipmentSchedule>()))
            .OccursOnce();

            var res = manager.GetEquipmentSchedule(5).Result;

            Assert.IsNotNull(res);
            EquipmentAccessor.Assert();
        }
Esempio n. 4
0
        public void EquipmentManager_GetAllEquipment()
        {
            EquipmentAccessor.Arrange(x => x.GetAllEquipment())
            .Returns(Task.FromResult(Enumerable.Empty <Equipment>()))
            .OccursOnce();

            var res = manager.GetAllEquipment().Result;

            Assert.IsNotNull(res);
            EquipmentAccessor.Assert();
        }
Esempio n. 5
0
        public void EquipmentManager_GetEquipmentSchedule_Values()
        {
            EquipmentAccessor.Arrange(x => x.GetEquipmentSchedule(5))
            .Returns(Task.FromResult(new List <EquipmentSchedule> {
                new EquipmentSchedule(), new EquipmentSchedule()
            }.AsEnumerable()))
            .OccursOnce();

            var res = manager.GetEquipmentSchedule(5).Result;

            Assert.IsNotNull(res);
            Assert.AreEqual(2, res.Count());
            EquipmentAccessor.Assert();
        }
Esempio n. 6
0
        public void EquipmentManager_GetEquipment_Values()
        {
            EquipmentAccessor.Arrange(x => x.GetEquipment(5))
            .Returns(Task.FromResult(new Equipment {
                Name = "test"
            }))
            .OccursOnce();

            var res = manager.GetEquipment(5).Result;

            Assert.IsNotNull(res);
            Assert.AreEqual("test", res.Name);
            EquipmentAccessor.Assert();
        }
Esempio n. 7
0
        public void EquipmentManager_SaveEquipment_Values()
        {
            var equip = new Equipment {
                EquipmentId = 5
            };
            var saveTask = Task <Equipment> .Factory.StartNew(() => { return(equip); });

            EquipmentAccessor.Arrange(x => x.SaveEquipment(equip))
            .Returns(saveTask)
            .OccursOnce();

            var res = manager.SaveEquipment(equip).Result;

            saveTask.Wait();
            Assert.IsNotNull(res);
            EquipmentAccessor.Assert();
        }
Esempio n. 8
0
        public void EquipmentManager_DeleteEquipment()
        {
            var saveTask = Task <Equipment> .Factory.StartNew(() => { return(new Equipment()); });

            EquipmentAccessor.Arrange(x => x.GetEquipment(Arg.IsAny <long>()))
            .Returns(Task.FromResult(new Equipment()))
            .OccursOnce();

            EquipmentAccessor.Arrange(x => x.SaveEquipment(Arg.IsAny <Equipment>()))
            .Returns(saveTask)
            .OccursOnce();

            var res = manager.DeleteEquipment(5).Result;

            saveTask.Wait();
            Assert.IsNotNull(res);
            Assert.IsTrue(res);
            EquipmentAccessor.Assert();
        }
Esempio n. 9
0
        public void EquipmentManager_DeleteEquipment_CatchException()
        {
            var saveTask = Task <Equipment> .Factory.StartNew(() => { return(new Equipment()); });

            EquipmentAccessor.Arrange(x => x.GetEquipment(5))
            .Returns(Task.FromResult(new Equipment {
                Deleted = false
            }))
            .OccursOnce();

            EquipmentAccessor.Arrange(x => x.SaveEquipment(Arg.Matches <Equipment>(y => y.Deleted)))
            .Throws(new Exception())
            .OccursOnce();

            var res = manager.DeleteEquipment(5).Result;

            saveTask.Wait();
            Assert.IsNotNull(res);
            Assert.IsFalse(res);
            EquipmentAccessor.Assert();
        }