コード例 #1
0
        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);
        }
コード例 #2
0
        public void EquipmentTypeManager_GetEquipmentTypes()
        {
            EquipmentTypeAccessor.Arrange(x => x.GetEquipmentTypes())
            .Returns(Task.FromResult(new List <EquipmentType>().AsEnumerable()))
            .OccursOnce();

            var res = manager.GetEquipmentTypes().Result;

            EquipmentTypeAccessor.Assert();
            Assert.IsNotNull(res);
            Assert.AreEqual(typeof(List <EquipmentType>), res.GetType());
        }
コード例 #3
0
        public void EquipmentTypeManager_SaveEquipmentType()
        {
            EquipmentTypeAccessor.Arrange(x => x.SaveEquipmentType(Arg.IsAny <EquipmentType>()))
            .Returns(Task.FromResult(new EquipmentType()))
            .OccursOnce();

            var res = manager.SaveEquipmentType(new EquipmentType()).Result;

            EquipmentTypeAccessor.Assert();
            Assert.IsNotNull(res);
            Assert.AreEqual(typeof(EquipmentType), res.GetType());
        }
コード例 #4
0
        public void EquipmentTypeManager_SaveEquipmentType_Values()
        {
            var equipmentType = new EquipmentType
            {
                Name    = "Type",
                Deleted = false
            };

            EquipmentTypeAccessor.Arrange(x => x.SaveEquipmentType(equipmentType))
            .Returns(Task.FromResult(equipmentType))
            .OccursOnce();

            var res = manager.SaveEquipmentType(equipmentType).Result;

            EquipmentTypeAccessor.Assert();
            Assert.IsNotNull(res);
            Assert.AreEqual(typeof(EquipmentType), res.GetType());
        }
コード例 #5
0
        public void EquipmentTypeManager_DeleteEquipmentType_Error()
        {
            var saveTask = Task <EquipmentType> .Factory.StartNew(() => { return(new EquipmentType()); });

            EquipmentTypeAccessor.Arrange(x => x.GetEquipmentType(Arg.IsAny <long>()))
            .Returns(Task.FromResult(new EquipmentType()))
            .OccursOnce();
            EquipmentTypeAccessor.Arrange(x => x.SaveEquipmentType(Arg.IsAny <EquipmentType>()))
            .Throws(new Exception())
            .OccursOnce();

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

            saveTask.Wait();
            EquipmentTypeAccessor.Assert();
            Assert.IsNotNull(res);
            Assert.IsFalse(res);
        }
コード例 #6
0
        public void EquipmentTypeManager_DeleteEquipmentType()
        {
            var saveTask = Task <EquipmentType> .Factory.StartNew(() => { return(new EquipmentType()); });

            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>().AsEnumerable()))
            .OccursOnce();


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

            saveTask.Wait();
            EquipmentTypeAccessor.Assert();
            EquipmentAccessor.Assert();
            Assert.IsNotNull(res);
            Assert.IsTrue(res);
        }