示例#1
0
        public void TestThatFoodGroupGetByForeignKeyReturnsFoodGroup()
        {
            var dataProvider = _systemDataRepository.DataProviderForFoodGroupsGet();

            Assert.That(dataProvider, Is.Not.Null);

            var foodGroup = _systemDataRepository.Insert(new FoodGroup {
                Parent = null, IsActive = true
            });

            try
            {
                // ReSharper disable PossibleInvalidOperationException
                var foreignKey = _systemDataRepository.Insert(new ForeignKey(dataProvider, foodGroup.Identifier.Value, foodGroup.GetType(), "ForeignKeyToFoodGroup"));
                // ReSharper restore PossibleInvalidOperationException
                try
                {
                    var result = _systemDataRepository.FoodGroupGetByForeignKey(dataProvider, "ForeignKeyToFoodGroup");
                    Assert.That(result, Is.Not.Null);
                    Assert.That(result.Identifier, Is.Not.Null);
                    // ReSharper disable ConditionIsAlwaysTrueOrFalse
                    Assert.That(result.Identifier.HasValue, Is.True);
                    // ReSharper restore ConditionIsAlwaysTrueOrFalse
                    // ReSharper disable PossibleInvalidOperationException
                    Assert.That(result.Identifier.Value, Is.EqualTo(foodGroup.Identifier.Value));
                    // ReSharper restore PossibleInvalidOperationException
                }
                finally
                {
                    _systemDataRepository.Delete(foreignKey);
                }
            }
            finally
            {
                _systemDataRepository.Delete(foodGroup);
            }
        }