コード例 #1
0
        public void Expenditures_are_shown_in_the_statements_when_server_is_DOWN()
        {
            var insertExpenditureAction = new InsertExpenditureAction();

            _tc.Run(new SetupUnavailableServer(), insertExpenditureAction);

            AssertTopStatementElement(insertExpenditureAction);
        }
コード例 #2
0
        private void AssertTopStatementElement(InsertExpenditureAction insertExpenditureAction)
        {
            var actual = TopStatementElement;

            Assert.AreEqual(insertExpenditureAction.CategoryId, actual.CategoryId);
            Assert.AreEqual(insertExpenditureAction.Sum, actual.Sum);
            Assert.AreEqual(_setupLocalSettings.CurrentCurrency, actual.CurrencyCode);
        }
コード例 #3
0
        private void AssertExpenditureWasPassedToServer(
            InsertExpenditureAction insertExpenditureAction, SetupExpendituresServer expendituresServer)
        {
            var actual = (expendituresServer.LastData as Expenditure[]).Single();

            Assert.AreEqual(insertExpenditureAction.CategoryId, actual.CategoryId);
            Assert.AreEqual(insertExpenditureAction.Sum, actual.Sum);
            Assert.AreEqual(_setupLocalSettings.CurrentCurrency, actual.CurrencyCode);
        }
コード例 #4
0
        public void Unsynchronized_expenditures_are_passed_to_the_server_when_it_is_UP()
        {
            var stubServer = new SetupExpendituresServer();
            var insertExpenditureAction = new InsertExpenditureAction();

            _tc.Run(
                new SetupUnavailableServer(),
                insertExpenditureAction,
                stubServer,
                new SynchronizationAction()
                );

            AssertExpenditureWasPassedToServer(insertExpenditureAction, stubServer);
            AssertThereAreNoUnsynchronizedItems();
            AssertExpenditureMatch(insertExpenditureAction, stubServer.ServerExpenditures.Single());
        }
コード例 #5
0
        public void Expenditures_are_shown_in_the_statements_starting_with_the_latest()
        {
            _tc.Run(new SetupExpendituresServer());
            var expenditure1 = new InsertExpenditureAction();
            var expenditure2 = new InsertExpenditureAction();
            var expenditure3 = new InsertExpenditureAction();
            var expenditureActionsByLatest = new[] { expenditure3, expenditure2, expenditure1 };

            _tc.Run(
                expenditure1,
                new AdvanceTimeAction(),
                expenditure2,
                new AdvanceTimeAction(),
                expenditure3);


            var expectedSums       = expenditureActionsByLatest.Select(x => x.Sum).ToArray();
            var expectedCategories = expenditureActionsByLatest.Select(x => x.CategoryId).ToArray();

            var actualStementElements = _tc.Kernel.Get <StatementViewModel>().StatementElements.ToArray();

            CollectionAssert.AreEqual(expectedSums, actualStementElements.Select(x => x.Sum).ToArray());
            CollectionAssert.AreEqual(expectedCategories, actualStementElements.Select(x => x.CategoryId).ToArray());
        }
コード例 #6
0
 private void AssertExpenditureMatch(InsertExpenditureAction action, Expenditure actualExpenditure)
 {
     Assert.AreEqual(action.CategoryId, actualExpenditure.CategoryId);
     Assert.AreEqual(action.Sum, actualExpenditure.Sum);
 }