Пример #1
0
        public void Save_SaveOnPersistenceWasCalled()
        {
            var           persist = new InMemoryPersistence();
            MainViewModel vm      = new MainViewModelBuilder()
                                    .WithPersistence(persist)
                                    .Build();

            vm.SaveDb();

            Assert.IsTrue(persist.SaveWasCalled);
        }
Пример #2
0
        private InMemoryPersistence FilledPersistence()
        {
            var persist = new InMemoryPersistence();

            persist.Add(new Statement("elephant is big", true));
            persist.Add(new Statement("mouse is small", true));
            persist.Add(new Statement("java is better than C#", false));
            persist.Add(new Statement(".net core is cross-platform", true));
            persist.Add(new Statement("byte equals 4 bits", false));

            return(persist);
        }
Пример #3
0
        public void OpenDb_DialogReturnsTrue_SaveCalledOnPersistence()
        {
            var dialogMock = new DialogServiceMock();
            var persist    = new InMemoryPersistence();

            var vm = new MainViewModelBuilder()
                     .WithPersistence(persist)
                     .WithDialogService(dialogMock)
                     .Build();

            vm.OpenDb();

            Assert.IsTrue(persist.LoadWasCalled);
            Assert.AreEqual(1, vm.CurrentNumber);
        }
Пример #4
0
        public void SaveDbAs_DialogReturnsTrue_SaveCalledOnPersistence()
        {
            var dialogMock = new DialogServiceMock();
            var persist    = new InMemoryPersistence();

            var vm = new MainViewModelBuilder()
                     .WithPersistence(persist)
                     .WithDialogService(dialogMock)
                     .Build();

            vm.SaveDbAs();

            Assert.IsTrue(persist.SaveWasCalled);
            Assert.IsTrue(dialogMock.SaveFileDialogWasCalled);
        }
Пример #5
0
        public void AddStatement_SomeStatement_AddsToPersistence()
        {
            var persist = new InMemoryPersistence();

            var vm = new MainViewModelBuilder()
                     .WithPersistence(persist)
                     .Build();

            vm.CurrentStatement.Text = "Text";

            vm.AddStatement();

            Assert.AreEqual(2, vm.CurrentNumber);
            Assert.AreEqual(1, persist.Count);

            Assert.IsEmpty(vm.CurrentStatement.Text);
            Assert.IsFalse(vm.CurrentStatement.IsTrue);
        }
Пример #6
0
        public void NewDb_DialogReturnsTrue_SaveCalledOnPersistenceAndVmIsInCorrectState()
        {
            var dialog  = new DialogServiceMock();
            var persist = new InMemoryPersistence();

            var vm = new MainViewModelBuilder()
                     .WithPersistence(persist)
                     .WithDialogService(dialog)
                     .Build();

            vm.NewDb();

            Assert.IsTrue(persist.SaveWasCalled);
            Assert.IsTrue(dialog.SaveFileDialogWasCalled);

            Assert.AreEqual(1, vm.CurrentNumber);
            Assert.IsTrue(vm.IsStatementEmpty);
            Assert.IsFalse(vm.CurrentStatement.IsTrue);
        }