public void TestThatTranslateDoesNotCallTranslateOnParentWhenParentIsNotNullAndHasBeenTranslated() { var cultureInfo = CultureInfo.CurrentUICulture; var parentFoodGroupIdentifier = Guid.NewGuid(); var parentFoodGroupMock = MockRepository.GenerateMock <IFoodGroup>(); parentFoodGroupMock.Stub(m => m.Identifier) .Return(parentFoodGroupIdentifier) .Repeat.Any(); parentFoodGroupMock.Stub(m => m.Translation) .Return(DomainObjectMockBuilder.BuildTranslationMock(parentFoodGroupIdentifier)) .Repeat.Any(); var foodGroup = new FoodGroup { Parent = parentFoodGroupMock }; Assert.That(foodGroup, Is.Not.Null); Assert.That(foodGroup.Parent, Is.Not.Null); Assert.That(foodGroup.Parent, Is.EqualTo(parentFoodGroupMock)); Assert.That(foodGroup.Parent.Translation, Is.Not.Null); foodGroup.Translate(cultureInfo); parentFoodGroupMock.AssertWasNotCalled(m => m.Translate(Arg <CultureInfo> .Is.Anything)); }
public void TestThatTranslateCallsTranslateOnParentWhenParentIsNotNullAndHasNotBeenTranslated() { var cultureInfo = CultureInfo.CurrentUICulture; var parentFoodGroupMock = MockRepository.GenerateMock <IFoodGroup>(); parentFoodGroupMock.Stub(m => m.Identifier) .Return(Guid.NewGuid()) .Repeat.Any(); parentFoodGroupMock.Stub(m => m.Translation) .Return(null) .Repeat.Any(); var foodGroup = new FoodGroup { Parent = parentFoodGroupMock }; Assert.That(foodGroup, Is.Not.Null); Assert.That(foodGroup.Parent, Is.Not.Null); Assert.That(foodGroup.Parent, Is.EqualTo(parentFoodGroupMock)); Assert.That(foodGroup.Parent.Translation, Is.Null); foodGroup.Translate(cultureInfo); parentFoodGroupMock.AssertWasCalled(m => m.Translate(Arg <CultureInfo> .Is.Equal(cultureInfo))); }