示例#1
0
        public void TestThatForeignKeysSetterSetForeignKeys()
        {
            var foodItem = new MyFoodItem
            {
                Identifier = Guid.NewGuid()
            };

            Assert.That(foodItem, Is.Not.Null);
            Assert.That(foodItem.Identifier, Is.Not.Null);
            Assert.That(foodItem.Identifier.HasValue, Is.True);
            Assert.That(foodItem.ForeignKeys, Is.Not.Null);
            Assert.That(foodItem.ForeignKeys, Is.Empty);

            // ReSharper disable PossibleInvalidOperationException
            var foreignKeyMockCollection = DomainObjectMockBuilder.BuildForeignKeyMockCollection(foodItem.Identifier.Value, foodItem.GetType());

            // ReSharper restore PossibleInvalidOperationException
            Assert.That(foreignKeyMockCollection, Is.Not.Null);
            Assert.That(foreignKeyMockCollection, Is.Not.Empty);

            foodItem.ForeignKeys = foreignKeyMockCollection;
            Assert.That(foodItem.ForeignKeys, Is.Not.Null);
            Assert.That(foodItem.ForeignKeys, Is.Not.Empty);
            Assert.That(foodItem.ForeignKeys, Is.EqualTo(foreignKeyMockCollection));
        }