public void ShouldEditVendorWithNoNameSpacePrefix()
        {
            var newVendorData = new Mock <IEditVendor>();

            newVendorData.Setup(v => v.VendorId).Returns(_vendorId);
            newVendorData.Setup(v => v.Company).Returns("new vendor name");
            newVendorData.Setup(v => v.NamespacePrefix).Returns(string.Empty);
            newVendorData.Setup(v => v.ContactName).Returns("new contact name");
            newVendorData.Setup(v => v.ContactEmailAddress).Returns("new contact email");

            Scoped <IUsersContext>(usersContext =>
            {
                var editVendorCommand = new EditVendorCommand(usersContext);
                editVendorCommand.Execute(newVendorData.Object);
            });

            Transaction(usersContext =>
            {
                var changedVendor = usersContext.Vendors.Single(v => v.VendorId == _vendorId);
                changedVendor.VendorName.ShouldBe("new vendor name");
                changedVendor.VendorNamespacePrefixes.ShouldBeEmpty();
                changedVendor.Users.First().FullName.ShouldBe("new contact name");
                changedVendor.Users.First().Email.ShouldBe("new contact email");
            });
        }
Example #2
0
        public async Task <IResult> Handle(EditVendorCommand editVendorCommand, IMapper mapper,
                                           Validator validator, Request request, int id)
        {
            request.VendorId = id;
            await validator.GuardAsync(request);

            var updatedVendor = editVendorCommand.Execute(request);
            var model         = mapper.Map <VendorModel>(updatedVendor);

            return(AdminApiResponse <VendorModel> .Updated(model, "Vendor"));
        }
        public void ShouldEditVendorWithContact()
        {
            var newVendorData = new Mock <IEditVendor>();

            newVendorData.Setup(v => v.VendorId).Returns(_vendorId);
            newVendorData.Setup(v => v.Company).Returns("new vendor name");
            newVendorData.Setup(v => v.NamespacePrefix).Returns("new namespace prefix");
            newVendorData.Setup(v => v.ContactName).Returns("new contact name");
            newVendorData.Setup(v => v.ContactEmailAddress).Returns("new contact email");

            var editVendorCommand = new EditVendorCommand(TestContext);

            editVendorCommand.Execute(newVendorData.Object);

            var changedVendor = TestContext.Vendors.Single(v => v.VendorId == _vendorId);

            changedVendor.VendorName.ShouldBe("new vendor name");
            changedVendor.VendorNamespacePrefixes.First().NamespacePrefix.ShouldBe("new namespace prefix");
            changedVendor.Users.First().FullName.ShouldBe("new contact name");
            changedVendor.Users.First().Email.ShouldBe("new contact email");
        }
 public GlobalSettingsController(IMapper mapper
                                 , IGetVendorsQuery getVendorsQuery
                                 , AddVendorCommand addVendorCommand
                                 , DeleteVendorCommand deleteVendorCommand
                                 , IGetVendorByIdQuery getVendorByIdQuery
                                 , EditVendorCommand editVendorCommand
                                 , ICloudOdsSettingsService cloudOdsSettingsService
                                 , ITabDisplayService tabDisplayService
                                 , IGetClaimSetsByApplicationNameQuery getClaimSetsByApplicationNameQuery
                                 , GetAdminAppUsersQuery getAdminAppUsersQuery)
 {
     _mapper                             = mapper;
     _getVendorsQuery                    = getVendorsQuery;
     _addVendorCommand                   = addVendorCommand;
     _deleteVendorCommand                = deleteVendorCommand;
     _getVendorByIdQuery                 = getVendorByIdQuery;
     _editVendorCommand                  = editVendorCommand;
     _cloudOdsSettingsService            = cloudOdsSettingsService;
     _tabDisplayService                  = tabDisplayService;
     _getClaimSetsByApplicationNameQuery = getClaimSetsByApplicationNameQuery;
     _getAdminAppUsersQuery              = getAdminAppUsersQuery;
 }
Example #5
0
        public void ShouldEditVendorByAddingMultipleNameSpacePrefixes()
        {
            var newVendorData = new Mock <IEditVendor>();

            Transaction(usersContext =>
            {
                var originalVendor = usersContext.Vendors.Single(v => v.VendorId == _vendorId);
                originalVendor.VendorNamespacePrefixes.Single().NamespacePrefix.ShouldBe(OriginalVendorNamespacePrefix);
            });
            var newNamespacePrefixes = new List <string>
            {
                "http://www.test1.com/",
                "http://www.test2.com/",
                "http://www.test3.com/"
            };

            newVendorData.Setup(v => v.VendorId).Returns(_vendorId);
            newVendorData.Setup(v => v.Company).Returns("new vendor name");
            newVendorData.Setup(v => v.NamespacePrefixes).Returns(newNamespacePrefixes.ToDelimiterSeparated());
            newVendorData.Setup(v => v.ContactName).Returns("new contact name");
            newVendorData.Setup(v => v.ContactEmailAddress).Returns("new contact email");

            Scoped <IUsersContext>(usersContext =>
            {
                var editVendorCommand = new EditVendorCommand(usersContext);
                editVendorCommand.Execute(newVendorData.Object);
            });

            Transaction(usersContext =>
            {
                var changedVendor = usersContext.Vendors.Single(v => v.VendorId == _vendorId);
                changedVendor.VendorName.ShouldBe("new vendor name");
                changedVendor.VendorNamespacePrefixes.Select(x => x.NamespacePrefix).ShouldBe(newNamespacePrefixes);
                changedVendor.Users.First().FullName.ShouldBe("new contact name");
                changedVendor.Users.First().Email.ShouldBe("new contact email");
            });
        }