Пример #1
0
        public void GetDefectsTest()
        {
            var mock = new Mock <IUnitOfWork>();

            mock.Setup(i => i.Defects.GetAll()).Returns(new List <DefectDAL>().AsQueryable());
            DefectService service = new DefectService(mock.Object);
            var           result  = service.GetDefects();

            Assert.IsAssignableFrom <IQueryable <DefectDTO> >(result);
        }
Пример #2
0
        public void AddDefectTest()
        {
            var mock = new Mock <IUnitOfWork>()
            {
                DefaultValue = DefaultValue.Mock
            };
            var newDefect = new DefectDTO()
            {
                Name        = "DefectName",
                Description = "DefectDescription"
            };
            DefectService service = new DefectService(mock.Object);

            service.AddDefect(newDefect);
            mock.Verify(i => i.Save());
        }
Пример #3
0
        public void GetDefectTest()
        {
            var mock = new Mock <IUnitOfWork>()
            {
                DefaultValue = DefaultValue.Mock
            };
            var newDefect = new DefectDTO()
            {
                Name        = "DefectName",
                Description = "DefectDescription"
            };
            DefectService service = new DefectService(mock.Object);

            service.AddDefect(newDefect);
            var result = service.GetDefect(newDefect.DefectId);

            Assert.Equal(newDefect.DefectId, result.DefectId);
            Assert.NotStrictEqual("DefectName", result.Name);
            Assert.NotStrictEqual("DefectDescription", result.Description);
        }