public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers() { // Setup var mocks = new MockRepository(); var projectObserver = mocks.StrictMock <IObserver>(); const int numberOfChangedProperties = 1; projectObserver.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties); var failureMechanism = mocks.StrictMock <ICalculatableFailureMechanism>(); mocks.ReplayAll(); var calculation = new TestCalculation(); var testCalculationContext = new TestCalculationContext(calculation, new CalculationGroup(), failureMechanism); calculation.Attach(projectObserver); var properties = new CalculationContextProperties { Data = testCalculationContext }; // Call const string newName = "Some new cool pretty name"; properties.Name = newName; // Assert Assert.AreEqual(newName, calculation.Name); mocks.VerifyAll(); }
public void DefaultConstructor_ExpectedValues() { // Call var properties = new CalculationContextProperties(); // Assert Assert.IsInstanceOf <ObjectProperties <ICalculationContext <ICalculation, ICalculatableFailureMechanism> > >(properties); Assert.IsNull(properties.Data); }
public void Constructor_ValidData_PropertiesHaveExpectedAttributeValues() { // Call var properties = new CalculationContextProperties(); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(1, dynamicProperties.Count); const string generalCategoryName = "Algemeen"; PropertyDescriptor nameProperty = dynamicProperties[0]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, generalCategoryName, "Naam", "Naam van de berekening."); }
public void GetProperties_WithData_ReturnExpectedValues() { // Setup const string name = "<very cool name>"; var calculation = new TestCalculation(name); var mocks = new MockRepository(); var failureMechanism = mocks.StrictMock <ICalculatableFailureMechanism>(); mocks.ReplayAll(); var properties = new CalculationContextProperties { Data = new TestCalculationContext(calculation, new CalculationGroup(), failureMechanism) }; // Call & Assert Assert.AreEqual(name, properties.Name); mocks.VerifyAll(); }