Пример #1
0
        public void GetByEmailTest()
        {
            Contact actual;
            string  email = "*****@*****.**";

            var entity1 = new CrmEntities.Contact();

            entity1.Id            = Guid.NewGuid();
            entity1.FirstName     = "Kate";
            entity1.LastName      = "O'conor";
            entity1.EMailAddress1 = "*****@*****.**";

            var entity2 = new CrmEntities.Contact();

            entity2.Id            = Guid.NewGuid();
            entity2.FirstName     = "John";
            entity2.LastName      = "Smith";
            entity2.EMailAddress1 = "*****@*****.**";

            var organisationService = new Microsoft.Xrm.Sdk.Fakes.StubIOrganizationService();

            organisationService.ExecuteOrganizationRequest = r =>
            {
                List <Entity> entities = new List <Entity>
                {
                    entity2
                };

                var response = new RetrieveMultipleResponse
                {
                    Results = new ParameterCollection
                    {
                        { "EntityCollection", new EntityCollection(entities) }
                    }
                };

                return(response);
            };

            var crmUnitOfWork = new Xrm.Infrastructure.DataAccess.Crm.Fakes.StubCrmUnitOfWork(organisationService, 10);
            var target        = new ContactRepository(organisationService, crmUnitOfWork);

            //
            // Act
            //
            actual = target.GetByEmail(email);

            //
            // Assert
            //
            Assert.IsNotNull(actual);
            Assert.AreEqual(entity2.EMailAddress1, actual.EmailAddress1);
        }
Пример #2
0
        public void GetByEmailTest()
        {
            Contact actual;
            string email = "*****@*****.**";

            var entity1 = new CrmEntities.Contact();
            entity1.Id = Guid.NewGuid();
            entity1.FirstName = "Kate";
            entity1.LastName = "O'conor";
            entity1.EMailAddress1 = "*****@*****.**";

            var entity2 = new CrmEntities.Contact();
            entity2.Id = Guid.NewGuid();
            entity2.FirstName = "John";
            entity2.LastName = "Smith";
            entity2.EMailAddress1 = "*****@*****.**";

            var organisationService = new Microsoft.Xrm.Sdk.Fakes.StubIOrganizationService();

            organisationService.ExecuteOrganizationRequest = r =>
            {
                List<Entity> entities = new List<Entity>
                {
                    entity2
                };

                var response = new RetrieveMultipleResponse
                {
                    Results = new ParameterCollection
                    {
                        { "EntityCollection", new EntityCollection(entities) }
                    }
                };

                return response;
            };

            var crmUnitOfWork = new Xrm.Infrastructure.DataAccess.Crm.Fakes.StubCrmUnitOfWork(organisationService, 10);
            var target = new ContactRepository(organisationService, crmUnitOfWork);

            //
            // Act
            //
            actual = target.GetByEmail(email);

            //
            // Assert
            //
            Assert.IsNotNull(actual);
            Assert.AreEqual(entity2.EMailAddress1, actual.EmailAddress1);
        }