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); }
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()); }
public void When_server_and_local_state_differ_successful_synchronization_updates_both_of_them() { _tc.Run(new SetupUnavailableServer()); var initialLocalExpenditures = InsertSampleExpenditures(); var initialServerExpenditures = _fixture.CreateMany <Expenditure>(); var setupStubServer = new SetupExpendituresServer().WithExpenditures(initialServerExpenditures); _tc.Run( setupStubServer, new SynchronizationAction()); var expectedAll = initialLocalExpenditures.Concat(initialServerExpenditures).ToArray(); AssertExpendituresAreStoredLocally(expectedAll); AssertExpendituresAreStoredInCache(expectedAll); AssertExpendituresAreStoredInServer(expectedAll, setupStubServer); }
private void AssertExpendituresAreStoredInServer(IEnumerable <Expenditure> initialServerExpenditures, SetupExpendituresServer server) { var expected = initialServerExpenditures.Select(e => e.Id).ToArray(); var actualServerExpendituresIds = server.ServerExpenditures.Select(e => e.Id).ToArray(); CollectionAssert.AreEquivalent(expected, actualServerExpendituresIds); }