コード例 #1
0
 public void One_element_different_integer_and_long_returns_false()
 {
     Tuple <string, object>[] s1 = new Tuple <string, object>[] { new Tuple <string, object>("a", 1L) };
     Tuple <string, object>[] s2 = new Tuple <string, object>[] { new Tuple <string, object>("a", 2) };
     Assert.IsFalse(U.PrimaryKeysEqual(s1, s2));
 }
コード例 #2
0
        public void UpdatePrimaryKeys_object_tree()
        {
            MockEntity entity = new MockEntity()
            {
                id = 1
            };

            entity.RelationalEntity1 = new MockEntity()
            {
                id = 2
            };
            entity.AssociativeEntities.Add(new MockAssociativeEntity()
            {
                RelationalEntity1Id = entity.id, RelationalEntity2Id = 3, RelationalEntity2 = new MockEntity()
                {
                    id = 3
                }
            });
            string jobPath = ".";
            string equipmentLocationPath = "RelationalEntity1";
            string jobContactsPath       = "AssociativeEntities[Guid=" + entity.AssociativeEntities.First().Guid + "]";
            string contactPath           = jobContactsPath + ".RelationalEntity2";

            IDictionary <string, Tuple <string, object>[]> keysToUpdate = new Dictionary <string, Tuple <string, object>[]>()
            {
                { jobPath, entity.PrimaryKeys },
                { equipmentLocationPath, entity.RelationalEntity1.PrimaryKeys },
                { jobContactsPath, entity.AssociativeEntities.First().PrimaryKeys },
                { contactPath, entity.AssociativeEntities.First().RelationalEntity2.PrimaryKeys }
            };

            MockEntity entityCopy = new MockEntity()
            {
                Guid = entity.Guid
            };

            entityCopy.RelationalEntity1 = new MockEntity()
            {
                Guid = entity.RelationalEntity1.Guid
            };
            entityCopy.AssociativeEntities.Add(new MockAssociativeEntity()
            {
                Guid = entity.AssociativeEntities.First().Guid, RelationalEntity2 = new MockEntity()
                {
                    Guid = entity.AssociativeEntities.First().RelationalEntity2.Guid
                }
            });

            Assert.AreEqual(EntityState.New, entityCopy.State);
            Assert.AreEqual(EntityState.New, entityCopy.RelationalEntity1.State);
            Assert.AreEqual(EntityState.New, entityCopy.AssociativeEntities.First().State);
            Assert.AreEqual(EntityState.New, entityCopy.AssociativeEntities.First().RelationalEntity2.State);

            U.UpdatePrimaryKeys(keysToUpdate, entityCopy);

            Assert.IsTrue(U.PrimaryKeysEqual(entity.PrimaryKeys, entityCopy.PrimaryKeys));
            Assert.IsTrue(U.PrimaryKeysEqual(entity.RelationalEntity1.PrimaryKeys, entityCopy.RelationalEntity1.PrimaryKeys));
            Assert.IsTrue(U.PrimaryKeysEqual(entity.AssociativeEntities.First().PrimaryKeys, entityCopy.AssociativeEntities.First().PrimaryKeys));
            Assert.IsTrue(U.PrimaryKeysEqual(entity.AssociativeEntities.First().RelationalEntity2.PrimaryKeys, entityCopy.AssociativeEntities.First().RelationalEntity2.PrimaryKeys));

            Assert.AreEqual(EntityState.Persisted, entityCopy.State);
            Assert.AreEqual(EntityState.Persisted, entityCopy.RelationalEntity1.State);
            Assert.AreEqual(EntityState.Persisted, entityCopy.AssociativeEntities.First().State);
            Assert.AreEqual(EntityState.Persisted, entityCopy.AssociativeEntities.First().RelationalEntity2.State);
        }
コード例 #3
0
 public void Two_different_mixed_type_elements_returns_false()
 {
     Tuple <string, object>[] s1 = new Tuple <string, object>[] { new Tuple <string, object>("a", 1), new Tuple <string, object>("b", "c") };
     Tuple <string, object>[] s2 = new Tuple <string, object>[] { new Tuple <string, object>("a", 2), new Tuple <string, object>("b", "d") };
     Assert.IsFalse(U.PrimaryKeysEqual(s1, s2));
 }
コード例 #4
0
 public void One_element_equal_integer_and_long_returns_true()
 {
     Tuple <string, object>[] s1 = new Tuple <string, object>[] { new Tuple <string, object>("a", 1L) };
     Tuple <string, object>[] s2 = new Tuple <string, object>[] { new Tuple <string, object>("a", 1) };
     Assert.IsTrue(U.PrimaryKeysEqual(s1, s2));
 }
コード例 #5
0
 public void Two_equal_mixed_type_elements_returns_true()
 {
     Tuple <string, object>[] s1 = new Tuple <string, object>[] { new Tuple <string, object>("a", 1), new Tuple <string, object>("b", "c") };
     Tuple <string, object>[] s2 = new Tuple <string, object>[] { new Tuple <string, object>("a", 1), new Tuple <string, object>("b", "c") };
     Assert.IsTrue(U.PrimaryKeysEqual(s1, s2));
 }
コード例 #6
0
 public void Two_different_string_elements_returns_false()
 {
     Tuple <string, object>[] s1 = new Tuple <string, object>[] { new Tuple <string, object>("a", "b"), new Tuple <string, object>("c", "d") };
     Tuple <string, object>[] s2 = new Tuple <string, object>[] { new Tuple <string, object>("a", "e"), new Tuple <string, object>("c", "f") };
     Assert.IsFalse(U.PrimaryKeysEqual(s1, s2));
 }
コード例 #7
0
 public void One_equal_string_element_returns_true()
 {
     Tuple <string, object>[] s1 = new Tuple <string, object>[] { new Tuple <string, object>("a", "b") };
     Tuple <string, object>[] s2 = new Tuple <string, object>[] { new Tuple <string, object>("a", "b") };
     Assert.IsTrue(U.PrimaryKeysEqual(s1, s2));
 }
コード例 #8
0
 public void Two_different_numeric_elements_returns_false()
 {
     Tuple <string, object>[] s1 = new Tuple <string, object>[] { new Tuple <string, object>("a", 1), new Tuple <string, object>("b", 2) };
     Tuple <string, object>[] s2 = new Tuple <string, object>[] { new Tuple <string, object>("a", 3), new Tuple <string, object>("b", 4) };
     Assert.IsFalse(U.PrimaryKeysEqual(s1, s2));
 }
コード例 #9
0
 public void Same_number_of_elements_different_keys_returns_false()
 {
     Tuple <string, object>[] s1 = new Tuple <string, object>[] { new Tuple <string, object>("a", 1L), new Tuple <string, object>("b", "c") };
     Tuple <string, object>[] s2 = new Tuple <string, object>[] { new Tuple <string, object>("c", 1), new Tuple <string, object>("d", "c") };
     Assert.IsFalse(U.PrimaryKeysEqual(s1, s2));
 }