예제 #1
0
        public void EnsureStaticDataAreCreated()
        {
            DatastoreModel model = new DataModelWithStaticData();

            model.Execute(false);

            Entity accountType = model.Entities["AccountType"];

            Assert.IsTrue(accountType.ContainsStaticData);
            Assert.IsNotNull(accountType.StaticData);
            Assert.IsTrue(accountType.StaticData.Count == 10);

            // TODO: Should it create a static data when HasStaticData == false ??
            Entity contactStatus = model.Entities["ContactStatus"];

            Assert.IsTrue(contactStatus.ContainsStaticData);
            Assert.IsNotNull(contactStatus.StaticData);
            Assert.IsTrue(contactStatus.StaticData.Count == 3);

            Entity referenceType = model.Entities["ReferenceType"];

            dynamic node = referenceType.Refactor.MatchNode("1");

            Assert.IsInstanceOf <DynamicEntity>(node);

            DynamicEntity nodeType = node as DynamicEntity;
            IReadOnlyDictionary <string, object> values = nodeType.GetDynamicEntityValues();

            Assert.AreEqual(values["Uid"], "1");
            Assert.AreEqual(values["Name"], "Opportunity");
            Assert.IsInstanceOf <List <string> >(values["Fields"]);
        }
예제 #2
0
        public void EnsureMatchNodeReturnsCorrectNode()
        {
            DatastoreModel model = new DataModelWithStaticData();

            model.Execute(true);

            Entity  accountType = model.Entities["AccountType"];
            dynamic account     = accountType.Refactor.MatchNode("6");

            Assert.IsInstanceOf <DynamicEntity>(account);

            DynamicEntity nodeType = account as DynamicEntity;
            IReadOnlyDictionary <string, object> values = nodeType.GetDynamicEntityValues();

            Assert.AreEqual(values["Uid"], "6");
            Assert.AreEqual(values["Name"], "Account");

            Assert.Throws <ArgumentNullException>(() => accountType.Refactor.MatchNode(null));
            Assert.Throws <InvalidCastException>(() => accountType.Refactor.MatchNode(6));
            Assert.Throws <ArgumentOutOfRangeException>(() => accountType.Refactor.MatchNode("7"));
        }