Esempio n. 1
0
        public void ProcessSingle_Exception_Catched()
        {
            // Arrange
            var ikep = new Mock <ITMRepositary>();

            ikep.Setup(s => s.GetFilesAsync()).Returns(
                Task <List <AnketaFile> > .Run(() => {
                return(new List <AnketaFile>());
            })
                );
            string message = ""; // Incoming paramater of IMessenger.ShowMessage
            var    imess   = new Mock <IMessenger>();

            imess.Setup(s => s.ShowMessage(It.IsAny <string>())).Callback <string>(r => message = r);

            Mock <IGeneralFacade> igf = FacadeWithSettingsCheck();
            var ipars = new FakeParser();

            igf.Setup(s => s.Parser).Returns(ipars);
            igf.Setup(s => s.Messenger).Returns(imess.Object);
            igf.Setup(s => s.Keeper).Returns(ikep.Object);
            var mod = new MainViewModel(igf.Object);

            // Act
            mod.CmdProcessMultithread.Execute(null);
            Thread.Sleep(100);
            mod.CmdStop.Execute(null);
            Thread.Sleep(200);
            // Assert
            StringAssert.Contains(message, "Test exception");
        }
Esempio n. 2
0
        public void ProcessSingle_Cancelation_Ok()
        {
            // Arrange
            var ikep = new Mock <ITMRepositary>();

            ikep.Setup(s => s.GetFilesAsync()).Returns(
                Task <List <AnketaFile> > .Run(() => {
                return(new List <AnketaFile>());
            })
                );
            var imess = new Mock <IMessenger>();

            Mock <IGeneralFacade> igf = FacadeWithSettingsCheck();
            var ipars = new FakeParser();

            igf.Setup(s => s.Parser).Returns(ipars);
            igf.Setup(s => s.Messenger).Returns(imess.Object);
            igf.Setup(s => s.Keeper).Returns(ikep.Object);
            var mod = new MainViewModel(igf.Object);

            // Act
            mod.CmdProcess.Execute(null);
            Thread.Sleep(100);
            mod.CmdStop.Execute(null);
            Thread.Sleep(200);
            // Assert
            Assert.True(
                (!mod.AllowStop) &&
                (!mod.StatuBarVisiblity)
                );
        }