コード例 #1
0
        public void ShouldAddVendorIfMultipleNamespacePrefixes()
        {
            var newVendor         = new Mock <IAddVendorModel>();
            var namespacePrefixes = new List <string>
            {
                "http://www.test1.com/",
                "http://www.test2.com/",
                "http://www.test3.com/"
            };

            newVendor.Setup(x => x.Company).Returns("test vendor");
            newVendor.Setup(x => x.NamespacePrefixes).Returns(namespacePrefixes.ToDelimiterSeparated());
            newVendor.Setup(x => x.ContactName).Returns("test user");
            newVendor.Setup(x => x.ContactEmailAddress).Returns("*****@*****.**");

            int id = 0;

            Scoped <IUsersContext>(usersContext =>
            {
                var command = new AddVendorCommand(usersContext);

                id = command.Execute(newVendor.Object).VendorId;
                id.ShouldBeGreaterThan(0);
            });

            Transaction(usersContext =>
            {
                var vendor = usersContext.Vendors.Single(v => v.VendorId == id);
                vendor.VendorName.ShouldBe("test vendor");
                vendor.VendorNamespacePrefixes.Select(x => x.NamespacePrefix).ShouldBe(namespacePrefixes);
                vendor.Users.Single().FullName.ShouldBe("test user");
                vendor.Users.Single().Email.ShouldBe("*****@*****.**");
            });
        }
コード例 #2
0
        public void ShouldAddVendor()
        {
            var newVendor = new Mock <IAddVendorModel>();

            newVendor.Setup(x => x.Company).Returns("test vendor");
            newVendor.Setup(x => x.NamespacePrefix).Returns("http://www.test.com/");
            newVendor.Setup(x => x.ContactName).Returns("test user");
            newVendor.Setup(x => x.ContactEmailAddress).Returns("*****@*****.**");

            int id = 0;

            Scoped <IUsersContext>(usersContext =>
            {
                var command = new AddVendorCommand(usersContext);

                id = command.Execute(newVendor.Object);
                id.ShouldBeGreaterThan(0);
            });

            Transaction(usersContext =>
            {
                var vendor = usersContext.Vendors.Single(v => v.VendorId == id);
                vendor.VendorName.ShouldBe("test vendor");
                vendor.VendorNamespacePrefixes.First().NamespacePrefix.ShouldBe("http://www.test.com/");
                vendor.Users.Single().FullName.ShouldBe("test user");
                vendor.Users.Single().Email.ShouldBe("*****@*****.**");
            });
        }
コード例 #3
0
        public async Task <IResult> Handle(Validator validator, AddVendorCommand addVendorCommand, IMapper mapper, Request request)
        {
            await validator.GuardAsync(request);

            var addedVendor = addVendorCommand.Execute(request);
            var model       = mapper.Map <VendorModel>(addedVendor);

            return(AdminApiResponse <VendorModel> .Created(model, "Vendor", $"/{FeatureConstants.Vendors}/{model.VendorId}"));
        }
コード例 #4
0
 public ActionResult AddVendor(AddVendorModel model)
 {
     _addVendorCommand.Execute(model);
     return(RedirectToActionJson <GlobalSettingsController>(x => x.Vendors(), "Vendor added successfully"));
 }