protected override void beforeEach() { Services.Inject <IObjectConverter>(new ObjectConverter()); Services.Inject <ISimplePropertyHandler <Case> >(Services.Container.GetInstance <SimplePropertyHandler <Case> >()); var theProperty = ReflectionHelper.GetProperty <Case>(c => c.Status); MockFor <IFieldAccessService>().Stub(x => x.RightsFor(typeof(Case), theProperty)).Return(AccessRight.All).IgnoreArguments(); theCase = new Case() { Status = "Open" }; Given = new UpdatePropertyModel <Case>() { Id = Guid.NewGuid(), PropertyName = "Status", PropertyValue = "Open", }; MockFor <IRepository>().Expect(x => x.Find <Case>(Given.Id)).Return(theCase); MockFor <IValidator>().Expect(x => x.Validate(null)).Return(Notification.Valid()).IgnoreArguments(); Output = ClassUnderTest.EditProperty(Given); }
protected override void beforeEach() { thePart = new Part { Name = "something" }; Services.Inject <ISimplePropertyHandler <Part> >(Services.Container.GetInstance <SimplePropertyHandler <Part> >()); var theProperty = ReflectionHelper.GetProperty <Part>(c => c.WarrantyDays); MockFor <IFieldAccessService>().Stub(x => x.RightsFor(thePart, theProperty)).Return(AccessRight.ReadOnly).Constraints(Is.Equal(thePart), Is.Matching <PropertyInfo>(x => x.Name == theProperty.Name)); var update = new UpdatePropertyModel <Part>() { Id = Guid.NewGuid(), PropertyName = "WarrantyDays", PropertyValue = "abc", }; MockFor <IRepository>().Stub(x => x.Find <Part>(update.Id)).Return(thePart); result = ClassUnderTest.EditProperty(update); }
protected override void beforeEach() { Services.Inject <IObjectConverter>(new ObjectConverter()); Services.Inject <ISimplePropertyHandler <Part> >(Services.Container.GetInstance <SimplePropertyHandler <Part> >()); var theProperty = ReflectionHelper.GetProperty <Part>(c => c.WarrantyDays); MockFor <IFieldAccessService>().Stub(x => x.RightsFor(typeof(Part), theProperty)).Return(AccessRight.All).IgnoreArguments(); thePart = new Part(); theInput = new UpdatePropertyModel <Part>() { Id = Guid.NewGuid(), PropertyName = "WarrantyDays", PropertyValue = "abc", }; MockFor <IRepository>().Expect(x => x.Find <Part>(theInput.Id)).Return(thePart); MockFor <IValidator>().Expect(x => x.Validate(null)).Return(Notification.Valid()).IgnoreArguments(); theOutput = ClassUnderTest.EditProperty(theInput); }