public void TestFieldDefaultValues() { var vm = new GageRRFieldViewModel(); var privateAccessor = new PrivateAccessor(vm); Assert.IsNull(privateAccessor.GetField("_detailsViewModel")); Assert.IsNull(privateAccessor.GetField("_settingsPropertyName")); Assert.IsNull(privateAccessor.GetField("_sourceProcessName")); Assert.IsNull(privateAccessor.GetField("_msaResults")); Assert.IsNull(privateAccessor.GetField("_dataGroupingItem")); Assert.IsNull(privateAccessor.GetField("_showItemSelectorCommand")); }
public void PropertiesTests() { //Testing public properties that have both getter and setter var vm = new GageRRFieldViewModel(); TestsHelper.TestPublicDeclaredPropertiesGetSet(vm, true); var vmPrivateAccessor = new PrivateAccessor(vm); var dataGroupingItemMock = Mock.Create<IInfoClass>(); Mock.Arrange(() => dataGroupingItemMock.Id).Returns(3); vmPrivateAccessor.SetField("_dataGroupingItem", dataGroupingItemMock); Mock.SetupStatic(typeof (LanguageService), Behavior.Loose); Mock.Arrange(() => LanguageService.Translate("Label_DataGroupingItemId")).Returns("Data Grouping Item"); Assert.AreEqual("Data Grouping Item: 3", vm.DataGroupingItemIdLabel); Assert.IsTrue(vm.ShowItemIdLabel); Mock.NonPublic.Arrange(vm, "ExecuteShowItemSelector", ArgExpr.IsAny<object>()).DoNothing().MustBeCalled(); vm.ShowItemSelectorCommand.Execute(null); Mock.NonPublic.Assert(vm, "ExecuteShowItemSelector", Occurs.Once(), ArgExpr.IsAny<object>()); }