Last active
August 29, 2015 14:01
-
-
Save dgwaldo/5d6d5fcbee464f2e50a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
public void LoadData_SendsUpdateStatusEvents() | |
{ | |
//Arrange | |
_mockEventAggregator.Setup(x => x.GetEvent<UpdateStatusEvent>().Publish(It.IsAny<string>())); | |
//Act | |
_materialMasterVm.LoadData().GetAwaiter(); | |
//Assert | |
_mockEventAggregator.Verify(x => x.GetEvent<UpdateStatusEvent>().Publish(It.IsAny<string>()), Times.Exactly(2)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
public void EventAggregator_ReceivesUpdatedUnitsEvent_CallsOnUnitsUpdated() | |
{ | |
//Arrange | |
_updateUnitsEvent = new UpdatedUnitsEvent(); //Use the real event not a mock... | |
//Setup the Moq EventAggregator to return our event | |
_mockEventAggregator.Setup(x => x.GetEvent<UpdatedUnitsEvent>()).Returns(_updateUnitsEvent); | |
_mockUnits.Object.DensitySolid = DensitySolidSymbols.KgCm3; | |
_mockUnits.Object.Pressure = PressureSymbols.KPa; | |
//Act | |
_updateUnitsEvent.Publish(_mockUnits.Object); //Trigger the event by publishing our payload | |
//Assert | |
_mockEventAggregator.Verify(x => x.GetEvent<UpdatedUnitsEvent>(), Times.Once); //Verify using Moq | |
var currentItem = _materialMasterVm.MaterialModels.CurrentItem as MaterialDetailViewModel;//Check behavior | |
Assert.AreEqual(DensitySolidSymbols.KgCm3, currentItem.Density.UserUnitType); | |
Assert.AreEqual(PressureSymbols.KPa, currentItem.YieldStress.UserUnitType); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment