Пример #1
0
        public void OnImportSatisfied_WhenCalled_SetsSystemOptions()
        {
            //Arrange
            var vm = new MainViewModel();
            var communicationServiceMock = Mock.Create<ICommunicationService>();
            vm.CommunicationService = communicationServiceMock;
            vm.ProcessBuilderRecentEntries = Mock.Create<IRecentEntryList>();
            vm.EventAggregator = Mock.Create<IEventAggregator>();
            vm.SystemOptionsWrapper = Mock.Create<ISystemOptionsWrapper>();

            var systemOptionsRetrieverMock = Mock.Create<SystemOptionsRetriever>();
            var sysOptionsMock = Mock.Create<SystemOptionsInfo>();
            Mock.Arrange(() => sysOptionsMock.SessionInactivityTimeoutAction).Returns(InactivityTimoutActionEnum.Locked);
            Mock.Arrange(() => sysOptionsMock.InactivityMinutes).Returns(5);
            Mock.Arrange(() => systemOptionsRetrieverMock.SystemOptions).Returns(sysOptionsMock);
            Mock.NonPublic.Arrange(vm, "StartInactivityTimer", ArgExpr.IsAny<SystemOptionsInfo>()).MustBeCalled();



            Mock.Arrange(
                () =>
                    vm.SystemOptionsWrapper.GetSystemOptions(
                        Arg.IsAny<EventHandler<DataPortalResult<SystemOptionsRetriever>>>()))
                .DoInstead<EventHandler<DataPortalResult<SystemOptionsRetriever>>>(
                    callback =>
                        callback(null,
                            new DataPortalResult<SystemOptionsRetriever>(systemOptionsRetrieverMock, null, null)));

            //Act
            vm.OnImportsSatisfied();

            //Assert
            vm.AssertAll();
        }