Exemple #1
0
        public static List <Solutions> GetAllSolutions(ISyncPolicyFactory _policy)
        {
            var frameworksDatastore = new FrameworksDatastore(DatastoreBaseSetup.CrmConnectionFactory, new Mock <ILogger <FrameworksDatastore> >().Object, _policy, _config);
            var frameworks          = frameworksDatastore.GetAll().ToList();
            var solnDatastore       = new SolutionsDatastore(DatastoreBaseSetup.CrmConnectionFactory, new Mock <ILogger <SolutionsDatastore> >().Object, _policy, _config);
            var allSolns            = frameworks.SelectMany(fw => solnDatastore.ByFramework(fw.Id)).ToList();

            return(allSolns);
        }
        public static List <Solutions> GetAllSolutions(ISyncPolicyFactory _policy)
        {
            var frameworksDatastore = new FrameworksDatastore(DatastoreBaseSetup.FrameworksDatastore, new Mock <ILogger <FrameworksDatastore> >().Object, _policy);
            var frameworks          = frameworksDatastore.GetAll().ToList();
            var solnDatastore       = new SolutionsDatastore(DatastoreBaseSetup.SolutionsDatastore, new Mock <ILogger <SolutionsDatastore> >().Object, _policy, _config, new Mock <IShortTermCache>().Object, new Mock <IServiceProvider>().Object);
            var allSolns            = frameworks.SelectMany(fw => solnDatastore.ByFramework(fw.Id)).ToList();

            return(allSolns);
        }
        public static List <Contacts> GetAllContacts(ISyncPolicyFactory _policy)
        {
            var frameworksDatastore = new FrameworksDatastore(DatastoreBaseSetup.FrameworksDatastore, new Mock <ILogger <FrameworksDatastore> >().Object, _policy);
            var frameworks          = frameworksDatastore.GetAll().ToList();
            var solnDatastore       = new SolutionsDatastore(DatastoreBaseSetup.SolutionsDatastore, new Mock <ILogger <SolutionsDatastore> >().Object, _policy, _config, new Mock <IShortTermCache>().Object, new Mock <IServiceProvider>().Object);
            var allSolns            = frameworks.SelectMany(fw => solnDatastore.ByFramework(fw.Id)).ToList();
            var allOrgIds           = allSolns.Select(soln => soln.OrganisationId).Distinct().ToList();
            var contactsDatastore   = new ContactsDatastore(DatastoreBaseSetup.ContactsDatastore, new Mock <ILogger <ContactsDatastore> >().Object, _policy, _config, new Mock <ILongTermCache>().Object);
            var allConts            = allOrgIds.SelectMany(orgId => contactsDatastore.ByOrganisation(orgId)).ToList();

            return(allConts);
        }
        public void BySolution_ReturnsData()
        {
            var frameworksDatastore = new FrameworksDatastore(DatastoreBaseSetup.CrmConnectionFactory, new Mock <ILogger <FrameworksDatastore> >().Object, _policy, _config);
            var frameworks          = frameworksDatastore.GetAll().ToList();
            var solnDatastore       = new SolutionsDatastore(DatastoreBaseSetup.CrmConnectionFactory, new Mock <ILogger <SolutionsDatastore> >().Object, _policy, _config);
            var allSolns            = frameworks.SelectMany(fw => solnDatastore.ByFramework(fw.Id)).ToList();
            var datastore           = new TechnicalContactsDatastore(DatastoreBaseSetup.CrmConnectionFactory, _logger, _policy, _config);

            var datas = allSolns.SelectMany(soln => datastore.BySolution(soln.Id)).ToList();

            datas.Should().NotBeEmpty();
            datas.ForEach(data => data.Should().NotBeNull());
            datas.ForEach(data => Verifier.Verify(data));
        }
        public void ById_ReturnsData()
        {
            var frameworksDatastore = new FrameworksDatastore(DatastoreBaseSetup.FrameworksDatastore, new Mock <ILogger <FrameworksDatastore> >().Object, _policy);
            var frameworks          = frameworksDatastore.GetAll().ToList();
            var solnDatastore       = new SolutionsDatastore(DatastoreBaseSetup.SolutionsDatastore, new Mock <ILogger <SolutionsDatastore> >().Object, _policy, _config, new Mock <IShortTermCache>().Object, new Mock <IServiceProvider>().Object);
            var allSolns            = frameworks.SelectMany(fw => solnDatastore.ByFramework(fw.Id));
            var ids = allSolns.Select(soln => soln.OrganisationId).Distinct().ToList();

            var datastore = new OrganisationsDatastore(DatastoreBaseSetup.OrganisationsDatastore, _logger, _policy, _config, new Mock <ILongTermCache>().Object);

            var datas = ids.Select(id => datastore.ById(id)).ToList();

            datas.Should().NotBeEmpty();
            datas.ForEach(data => data.Should().NotBeNull());
            datas.ForEach(data => Verifier.Verify(data));
        }
Exemple #6
0
        public void ByContact_ReturnsData()
        {
            var frameworksDatastore = new FrameworksDatastore(DatastoreBaseSetup.CrmConnectionFactory, new Mock <ILogger <FrameworksDatastore> >().Object, _policy, _config);
            var frameworks          = frameworksDatastore.GetAll().ToList();
            var solnDatastore       = new SolutionsDatastore(DatastoreBaseSetup.CrmConnectionFactory, new Mock <ILogger <SolutionsDatastore> >().Object, _policy, _config);
            var allSolns            = frameworks.SelectMany(fw => solnDatastore.ByFramework(fw.Id));
            var allOrgIds           = allSolns.Select(soln => soln.OrganisationId).Distinct().ToList();
            var contactsDatastore   = new ContactsDatastore(DatastoreBaseSetup.CrmConnectionFactory, new Mock <ILogger <ContactsDatastore> >().Object, _policy, _config, new Mock <IDatastoreCache>().Object);
            var allContacts         = allOrgIds.SelectMany(orgId => contactsDatastore.ByOrganisation(orgId)).ToList();
            var datastore           = new OrganisationsDatastore(DatastoreBaseSetup.CrmConnectionFactory, _logger, _policy, _config, new Mock <IDatastoreCache>().Object);

            var datas = allContacts.Select(contact => datastore.ByContact(contact.Id)).ToList();

            datas.Should().NotBeEmpty();
            datas.ForEach(data => data.Should().NotBeNull());
            datas.ForEach(data => Verifier.Verify(data));
        }
        public void CRUD_Succeeds()
        {
            var frameworksDatastore = new FrameworksDatastore(DatastoreBaseSetup.CrmConnectionFactory, new Mock <ILogger <FrameworksDatastore> >().Object, _policy, _config);
            var frameworks          = frameworksDatastore.GetAll().ToList();
            var solnDatastore       = new SolutionsDatastore(DatastoreBaseSetup.CrmConnectionFactory, new Mock <ILogger <SolutionsDatastore> >().Object, _policy, _config);
            var soln      = frameworks.SelectMany(fw => solnDatastore.ByFramework(fw.Id)).First();
            var datastore = new TechnicalContactsDatastore(DatastoreBaseSetup.CrmConnectionFactory, _logger, _policy, _config);

            // create
            var newEnt = Creator.GetTechnicalContact(solutionId: soln.Id, contactType: "Lead Contact", emailAddress: "*****@*****.**");

            newEnt.FirstName   = "Steve";
            newEnt.LastName    = "Gray";
            newEnt.PhoneNumber = "1234567890";
            var createdEnt = datastore.Create(newEnt);

            try
            {
                createdEnt.Should().BeEquivalentTo(newEnt);

                // update
                createdEnt.FirstName = "Jon";
                createdEnt.LastName  = "Dough";
                datastore.Update(createdEnt);
                datastore.BySolution(soln.Id).Single(ent => ent.Id == createdEnt.Id)
                .Should().BeEquivalentTo(createdEnt);
            }
            finally
            {
                // delete
                datastore.Delete(createdEnt);
            }

            // delete
            datastore.BySolution(soln.Id)
            .Should().NotContain(ent => ent.Id == createdEnt.Id);
        }