Esempio n. 1
0
 internal static Tag ToTag(this SimpleTagDto dto, long userId)
 {
     return(new Tag
     {
         Name = dto.Name,
         UserId = userId
     });
 }
        public void Test01SetupSimpleDto()
        {
            //SETUP

            //ATTEMPT
            var dto = new SimpleTagDto();

            //VERIFY
            dto.NeedsDecompile.ShouldEqual(false);
        }
        public void Test01SetupSimpleDto()
        {
            //SETUP

            //ATTEMPT
            var dto = new SimpleTagDto();

            //VERIFY
            dto.NeedsDecompile.ShouldEqual(false);
        }
        public void Check02CreateFailOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new CreateService<Tag, SimpleTagDto>(db);
                var dto = new SimpleTagDto();
                dto.SetSupportedFunctions( CrudFunctions.None);

                //ATTEMPT
                var status = service.Create(dto);

                //VERIFY
                status.IsValid.ShouldEqual(false);
                status.Errors.Count.ShouldEqual(1);
                status.Errors[0].ErrorMessage.ShouldEndWith("is not supported in this mode.");
                dto.FunctionsCalledCommaDelimited.ShouldEqual("");
            }
        }
Esempio n. 5
0
        public void Check02UpdateFailOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new UpdateService <Tag, SimpleTagDto>(db);
                var dto     = new SimpleTagDto();
                dto.SetSupportedFunctions(CrudFunctions.None);

                //ATTEMPT
                var status = service.Update(dto);

                //VERIFY
                status.IsValid.ShouldEqual(false);
                status.Errors.Count.ShouldEqual(1);
                status.Errors[0].ErrorMessage.ShouldEndWith("is not supported in this mode.");
                dto.FunctionsCalledCommaDelimited.ShouldEqual("");
            }
        }
Esempio n. 6
0
        public void Check02CreateFlow(InstrumentedOpFlags errorFlag, bool isValid, string expectedFunctionsCalled)
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new CreateService <Tag, SimpleTagDto>(db);
                var dto     = new SimpleTagDto(errorFlag)
                {
                    Name = "Test Name",
                    Slug = Guid.NewGuid().ToString("N")
                };

                //ATTEMPT
                var status = service.Create(dto);

                //VERIFY
                status.IsValid.ShouldEqual(isValid);
                dto.FunctionsCalledCommaDelimited.ShouldEqual(expectedFunctionsCalled);
            }
        }
Esempio n. 7
0
        public void Check02UpdateFlow(InstrumentedOpFlags errorFlag, bool isValid, string expectedFunctionsCalled)
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new UpdateService <Tag, SimpleTagDto>(db);
                var dto     = new SimpleTagDto(errorFlag)
                {
                    TagId = db.Tags.First().TagId,
                    Name  = "Test Name",
                    Slug  = Guid.NewGuid().ToString("N")
                };

                //ATTEMPT
                //dto.CopyDtoToData(db, dto, new Tag());          //do this to preload AutoMapper
                var status = service.Update(dto);

                //VERIFY
                status.IsValid.ShouldEqual(isValid);
                dto.FunctionsCalledCommaDelimited.ShouldEqual(expectedFunctionsCalled);
            }
        }
        public void Check02CreateFlow(InstrumentedOpFlags errorFlag, bool isValid, string expectedFunctionsCalled)
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new CreateService<Tag, SimpleTagDto>(db);
                var dto = new SimpleTagDto(errorFlag)
                {
                    Name = "Test Name",
                    Slug = Guid.NewGuid().ToString("N")
                };

                //ATTEMPT
                var status = service.Create(dto);

                //VERIFY
                status.IsValid.ShouldEqual(isValid);
                dto.FunctionsCalledCommaDelimited.ShouldEqual(expectedFunctionsCalled);
            }
        }  
        public void Check02UpdateFlow(InstrumentedOpFlags errorFlag, bool isValid, string expectedFunctionsCalled)
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new UpdateService<Tag, SimpleTagDto>(db);
                var dto = new SimpleTagDto(errorFlag)
                {
                    TagId = db.Tags.First().TagId,
                    Name = "Test Name",
                    Slug = Guid.NewGuid().ToString("N")
                };

                //ATTEMPT
                //dto.CopyDtoToData(db, dto, new Tag());          //do this to preload AutoMapper
                var status = service.Update(dto);

                //VERIFY
                status.IsValid.ShouldEqual(isValid);
                dto.FunctionsCalledCommaDelimited.ShouldEqual(expectedFunctionsCalled);
            }
        }