public void InitializeTest() { var actionManagerVM = Mock.Create<ActionManagerViewModel>(); var actionItemInfo = new ActionItemInfo(123, "ProcessName", "7FA27365-AF0A-4F98-A927-368D21A8175A", 321, "Name", "Subject", "Message", ActionTypes.Approval, "GroupName", new DateTime(2012, 1, 16), true, false); var vm = new ActionItemViewModel(); var changedProperties = new List<string>(); vm.PropertyChanged += (o, e) => changedProperties.Add(e.PropertyName); var dynamicManagerMock = Mock.Create<IDynamicTypeManager>(); Mock.Arrange(() => dynamicManagerMock.BeginGetEditableRoot(Constants.ActionItemsProcessName, 1, Arg.IsAny<Action<object, DataPortalResult<IEditableRoot>>>())) .DoInstead<string, int, Action<object, DataPortalResult<IEditableRoot>>>( (processName, id, callback) => { var result = new DataPortalResult<IEditableRoot>(null, null, null); callback(null, result); }); vm.DynamicManager = dynamicManagerMock; vm.Initialize(actionItemInfo, actionManagerVM); Assert.AreSame(actionItemInfo, vm.Model); Assert.AreSame(actionManagerVM, vm.ParentViewModel); Assert.AreEqual(actionItemInfo.Subject, vm.Subject); Assert.AreEqual(actionItemInfo.Message, vm.Description); Assert.AreEqual(actionItemInfo.GroupName, vm.GroupName); Assert.AreEqual(actionItemInfo.DueDate, vm.DueDate); Assert.AreEqual(actionItemInfo.IsActionNew, vm.IsActionNew); Assert.IsTrue(changedProperties.Contains("Model")); Assert.IsTrue(changedProperties.Contains("AcknowledgeVisible")); Assert.IsTrue(changedProperties.Contains("AcknowledgeCollapse")); Assert.IsTrue(changedProperties.Contains("Subject")); Assert.IsTrue(changedProperties.Contains("Description")); Assert.IsTrue(changedProperties.Contains("GroupName")); Assert.IsTrue(changedProperties.Contains("DueDate")); Assert.IsTrue(changedProperties.Contains("IsLate")); Assert.IsTrue(changedProperties.Contains("IsActionNew")); }
public void OpenScreenCommandTest() { var actionManagerVM = Mock.Create<ActionManagerViewModel>(); var actionItemInfo = new ActionItemInfo( 123, "ProcessName", "7FA27365-AF0A-4F98-A927-368D21A8175A", 321, "Name", "Subject", "Message", ActionTypes.Approval, "GroupName", DateTime.MinValue, true, false); var detailsMock = Mock.Create<IDetailsViewModel>(); var shellMock = Mock.Create<IShell>(); var vm = new ActionItemViewModel { DetailsViewModelFactory = new ExportFactory<IDetailsViewModel>(() => new Tuple<IDetailsViewModel, Action>(detailsMock, () => { })), WindowManager = shellMock }; var dynamicManagerMock = Mock.Create<IDynamicTypeManager>(); Mock.Arrange(() => dynamicManagerMock.BeginGetEditableRoot(Constants.ActionItemsProcessName, 1, Arg.IsAny<Action<object, DataPortalResult<IEditableRoot>>>())) .DoInstead<string, int, Action<object, DataPortalResult<IEditableRoot>>>( (processName, id, callback) => { var result = new DataPortalResult<IEditableRoot>(null, null, null); callback(null, result); }); vm.DynamicManager = dynamicManagerMock; vm.Initialize(actionItemInfo, actionManagerVM); vm.IsDetailOpen = true; vm.OpenScreenCommand.Execute(null); Assert.IsFalse(vm.IsDetailOpen); Mock.Assert(() => detailsMock.Refresh(actionItemInfo.ProcessName, actionItemInfo.ItemId), Occurs.Once()); Mock.Assert(() => shellMock.ShowTaskWindow(detailsMock, true), Occurs.Once()); }
public void OpenScreenCommandOpensIntegrationEvent() { // Arrange. var actionItem = new ActionItemInfo( 123, Constants.IntegrationEventProcessName, "7FA27365-AF0A-4F98-A927-368D21A8175A", 321, "Integration Service Failed", "Subject", "Message", ActionTypes.Assignment, "GroupName", DateTime.MinValue, true, true); var windowManager = Mock.Create<IShell>(Behavior.Loose); var actionManager = new ActionManagerViewModel(); var integrationEventViewModel = Mock.Create<IIntegrationEventViewModel>(Behavior.Loose); var integrationEventViewModelFactory = Mock.Create<IIntegrationEventViewModelFactory>(Behavior.Loose); Mock.Arrange(() => integrationEventViewModelFactory.CreateViewModel()).Returns(integrationEventViewModel); var viewModel = new ActionItemViewModel { WindowManager = windowManager, IntegrationEventViewModelFactory = integrationEventViewModelFactory }; viewModel.Initialize(actionItem, actionManager); // Act. viewModel.OpenScreenCommand.Execute(null); // Assert. Mock.Assert(() => integrationEventViewModel.LoadEvent(321), Occurs.Once()); Mock.Assert(() => windowManager.ShowTaskWindow(integrationEventViewModel, true), Occurs.Once()); }
public void AcknowledgeCollapseTest() { var actionManagerVM = Mock.Create<ActionManagerViewModel>(); var actionItemInfo = new ActionItemInfo( 123, "ProcessName", "7FA27365-AF0A-4F98-A927-368D21A8175A", 321, "Name", "Subject", "Message", ActionTypes.Approval, "GroupName", DateTime.MinValue, true, false); var vm = new ActionItemViewModel(); var dynamicManagerMock = Mock.Create<IDynamicTypeManager>(); Mock.Arrange(() => dynamicManagerMock.BeginGetEditableRoot(Constants.ActionItemsProcessName, 1, Arg.IsAny<Action<object, DataPortalResult<IEditableRoot>>>())) .DoInstead<string, int, Action<object, DataPortalResult<IEditableRoot>>>( (processName, id, callback) => { var result = new DataPortalResult<IEditableRoot>(null, null, null); callback(null, result); }); vm.DynamicManager = dynamicManagerMock; vm.Initialize(actionItemInfo, actionManagerVM); Assert.AreEqual(Visibility.Visible, vm.AcknowledgeCollapse); actionItemInfo = new ActionItemInfo( 123, "ProcessName", "7FA27365-AF0A-4F98-A927-368D21A8175A", 321, "Name", "Subject", "Message", ActionTypes.Assignment, "GroupName", DateTime.MinValue, true, false); vm.Initialize(actionItemInfo, actionManagerVM); Assert.AreEqual(Visibility.Collapsed, vm.AcknowledgeCollapse); }