public async Task SavingAndLoading_ShouldProduceTheSameCheckSum() { var subject1 = CreateSubject(); await subject1.SaveAsync(LedgerBookTestData.TestData2(), "Foo2.xml", false); var serialisedData = subject1.SerialisedData; Debug.WriteLine("Saved / Serialised Xml:"); Debug.WriteLine(serialisedData); LedgerBookDto bookDto; var subject2 = CreateSubject(); subject2.FileExistsOverride = f => true; subject2.LoadXamlFromDiskFromEmbeddedResources = false; this.mockReaderWriter.Setup(m => m.LoadFromDiskAsync(It.IsAny <string>())).ReturnsAsync(serialisedData); await subject2.LoadAsync("foo", false); bookDto = subject2.LedgerBookDto; int checksumPosition = serialisedData.IndexOf("CheckSum=\"", StringComparison.OrdinalIgnoreCase); int checksumLength = serialisedData.IndexOf('"', checksumPosition + 11) - checksumPosition; string serialisedCheckSum = serialisedData.Substring(checksumPosition + 10, checksumLength - 10); Assert.AreEqual(double.Parse(serialisedCheckSum), bookDto.Checksum); }
public async Task Load_ShouldCreateBookWithSameName() { XamlOnDiskLedgerBookRepository subject = CreateSubject(); var book = await subject.LoadAsync(LoadFileName, false); var testData2 = LedgerBookTestData.TestData2(); Assert.AreEqual(testData2.Name, book.Name); }
public async Task Load_ShouldCreateBookWithSameNumberOfReconciliations() { XamlOnDiskLedgerBookRepository subject = CreateSubject(); var book = await subject.LoadAsync(LoadFileName, false); var testData2 = LedgerBookTestData.TestData2(); Assert.AreEqual(testData2.Reconciliations.Count(), book.Reconciliations.Count()); }
public void TestInitialise() { Subject = new BurnDownChartAnalyser(new LedgerCalculation(), new FakeLogger()); Budget = BudgetModelTestData.CreateTestData2(); LedgerBook = LedgerBookTestData.TestData2(); StatementModel = StatementModelTestData.TestData3(); Act(); }
public async Task Load_ShouldCreateBookWithFirstLineEqualBankBalances() { XamlOnDiskLedgerBookRepository subject = CreateSubject(); var book = await subject.LoadAsync(LoadFileName, false); var testData2 = LedgerBookTestData.TestData2(); var line = book.Reconciliations.First(); Assert.AreEqual(testData2.Reconciliations.First().TotalBankBalance, line.TotalBankBalance); }
public async Task Load_Output() { XamlOnDiskLedgerBookRepository subject = CreateSubject(); var book = await subject.LoadAsync(LoadFileName, false); // Visual compare these two - should be the same LedgerBookTestData.TestData2().Output(); book.Output(); }
public async Task Save_ShouldSaveTheXmlFile() { var fileName = @"CompleteSmellyFoo.xml"; XamlOnDiskLedgerBookRepository subject = CreateSubject(); var testData = LedgerBookTestData.TestData2(); await subject.SaveAsync(testData, fileName, false); this.mockReaderWriter.Verify(m => m.WriteToDiskAsync(It.IsAny <string>(), It.IsAny <string>())); }
public void TestInitialise() { var accountRepo = new InMemoryAccountTypeRepository(); var subject = new Mapper_LedgerEntryDto_LedgerEntry(new LedgerBucketFactory(new BucketBucketRepoAlwaysFind(), accountRepo), new LedgerTransactionFactory(), accountRepo); Result = subject.ToModel(TestData); LedgerBook book = LedgerBookTestData.TestData2(); Control = book.Reconciliations.First(l => l.Date == new DateTime(2013, 08, 15)).Entries.First(e => e.LedgerBucket.BudgetBucket.Code == TestDataConstants.PowerBucketCode); }
public async Task SerialiseTestData2ToEnsureItMatches_Load_ShouldLoadTheXmlFile_xml() { var subject = CreateSubject(); await subject.SaveAsync(LedgerBookTestData.TestData2(), "Leonard Nimoy.xml", false); var serialisedData = subject.SerialisedData; Console.WriteLine(serialisedData); Assert.IsTrue(serialisedData.Length > 100); }
public async Task SaveAsync_ShouldHaveACheckSumOf8435_GivenLedgerBookTestData2() { var subject = CreateSubject(); await subject.SaveAsync(LedgerBookTestData.TestData2(), "Foo.xml", false); var serialisedData = subject.SerialisedData; int checksumPosition = serialisedData.IndexOf("CheckSum=\"", StringComparison.OrdinalIgnoreCase); int checksumLength = serialisedData.IndexOf('"', checksumPosition + 11) - checksumPosition; string serialisedCheckSum = serialisedData.Substring(checksumPosition + 10, checksumLength - 10); Assert.AreEqual(8435.06, double.Parse(serialisedCheckSum)); }
public async Task Load_ShouldCreateBookWithFirstLineEqualSurplus() { XamlOnDiskLedgerBookRepository subject = CreateSubject(); var book = await subject.LoadAsync(LoadFileName, false); book.Output(); var testData2 = LedgerBookTestData.TestData2(); testData2.Output(); var line = book.Reconciliations.First(); Assert.AreEqual(testData2.Reconciliations.First().CalculatedSurplus, line.CalculatedSurplus); }
public void TestInitialise() { TestData = LedgerBookTestData.TestData2(); }
public void UsingTestData2_Output() { var book = LedgerBookTestData.TestData2(); book.Output(); }