コード例 #1
0
        public void DeleteWithNoQueryResultsThrowsNoError()
        {
            var context    = new XrmFakedContext();
            var orgService = context.GetOrganizationService();

            Assert.DoesNotThrow(
                () => SampleAccountQueryExpression.DeleteSingleRecord(orgService));
        }
コード例 #2
0
        public void IfNoResultsAreFoundReturnsNull()
        {
            var context    = new XrmFakedContext();
            var orgService = context.GetOrganizationService();

            var retrievedAccount = (Account)SampleAccountQueryExpression.RetrieveSingleRecord(orgService);

            Assert.IsNull(retrievedAccount);
        }
コード例 #3
0
        public void QueryExpressionEntityCollectionExtensionMethod()
        {
            var context    = new XrmFakedContext();
            var orgService = context.GetOrganizationService();

            context.Initialize(new List <Entity>()
            {
                TestAccount1,
                TestAccount1Duplicate
            });

            var retrievedAccounts = SampleAccountQueryExpression.RetrieveMultiple(orgService);

            Assert.AreEqual(2, retrievedAccounts.Entities.Count);
        }
コード例 #4
0
        public void QueryExpressionSingleRecordExtensionMethod()
        {
            var context    = new XrmFakedContext();
            var orgService = context.GetOrganizationService();

            context.Initialize(new List <Entity>()
            {
                TestAccount1
            });

            var retrievedAccount = (Account)SampleAccountQueryExpression.RetrieveSingleRecord(orgService);

            Assert.AreEqual(TestAccount1.Id, retrievedAccount.Id);
            Assert.AreEqual(TestAccount1.Name, retrievedAccount.Name);
        }
コード例 #5
0
        public void DeleteSingleRecordTest()
        {
            var context    = new XrmFakedContext();
            var orgService = context.GetOrganizationService();

            context.Initialize(new List <Entity>()
            {
                TestAccount1
            });

            var preAccounts = (from a in context.CreateQuery <Account>()
                               select a).ToList();

            Assert.AreEqual(1, preAccounts.Count);
            Assert.DoesNotThrow(
                () => SampleAccountQueryExpression.DeleteSingleRecord(orgService));

            var postAccounts = (from a in context.CreateQuery <Account>()
                                select a).ToList();

            Assert.AreEqual(0, postAccounts.Count);
        }