public void TestInsertAndUpdateByUid()
        {
            JournalProxy proxy  = new JournalProxy();
            JournalDto   insert = CreateJournalDto();

            proxy.Insert(insert);

            Assert.IsTrue(insert.Uid > 0, "Uid must be > 0 after save.");

            JournalDto read = (JournalDto)proxy.GetByUid(insert.Uid);

            read.Notes = "Updated";

            // change Total and Flip Them Around
            read.Items[0].Amount = 345.78M;
            read.Items[0].Type   = DebitCreditType.Debit;

            read.Items[1].Amount = 345.78M;
            read.Items[1].Type   = DebitCreditType.Credit;

            proxy.Update(read);

            JournalDto updated = (JournalDto)proxy.GetByUid(insert.Uid);

            ReflectionTester.AssertAreEqual("Journal", read, updated);
        }
        public void TestInsertAndGetByUid()
        {
            JournalProxy proxy  = new JournalProxy();
            JournalDto   insert = CreateJournalDto();

            proxy.Insert(insert);

            Assert.IsTrue(insert.Uid > 0, "Uid must be > 0 after save.");

            JournalDto read = (JournalDto)proxy.GetByUid(insert.Uid);

            ReflectionTester.AssertAreEqual("Journal", insert, read, new[] { "Tags" });
        }
        public void Update()
        {
            JournalProxy proxy = new JournalProxy();
            JournalDto   dto   = CreateJournalDto();

            proxy.Insert(dto);

            Assert.IsTrue(dto.Uid > 0, "Uid must be > 0 after save.");

            dto.Summary = "Add some summary.";
            dto.Notes   = "Updated journal.";
            proxy.Update(dto);

            JournalDto read = (JournalDto)proxy.GetByUid(dto.Uid);

            ReflectionTester.AssertAreEqual("Journal", dto, read, new[] { "LastModified", "Tags" });
        }
        public void TestInsertMultiCcy1()
        {
            JournalProxy proxy  = new JournalProxy();
            JournalDto   insert = CreateJournalDto2();

            proxy.Insert(insert);
            Assert.IsTrue(insert.Uid > 0, "Uid must be > 0 after save.");

            JournalDto read = (JournalDto)proxy.GetByUid(insert.Uid);

            Assert.IsTrue(read.FCToBCFXRate > 0, "FX Rate should have been auto-populated.");

            // For comparison, set the original rate to the one set by Saasu.
            insert.FCToBCFXRate = read.FCToBCFXRate;

            ReflectionTester.AssertAreEqual("Journal", insert, read, new[] { "LastModified", "Tags" });
        }
        public void Delete()
        {
            JournalProxy proxy = new JournalProxy();
            JournalDto   dto   = CreateJournalDto();

            proxy.Insert(dto);

            proxy.DeleteByUid(dto.Uid);

            try
            {
                JournalDto fromDB = (JournalDto)proxy.GetByUid(dto.Uid);
                Assert.Fail("The Journal Entry was not deleted successfully.");
            }
            catch (RestException ex)
            {
                Assert.IsTrue(ex.Type == "RecordNotFoundException");
            }
        }
		public void TestRemovalOfAsciiControlCharacters()
		{
			var proxy = new JournalProxy();
			var dto = CreateJournalDto();
			proxy.Insert(dto);

			Assert.IsTrue(dto.Uid > 0, "Uid must be > 0 after save.");

			// Ascii control characters in the summary string below are not visible in visual studio. you need to copy this string to notepad++ to view the non printable characters
			const string summaryTextWithControlCharacters = "Control characters start between these hashes ##  ## control characters end";
			const string summaryTextWithoutControlCharacters = "Control characters start between these hashes ##  ## control characters end";
			dto.Summary = summaryTextWithControlCharacters;

			proxy.Update(dto);

			var read = (JournalDto)proxy.GetByUid(dto.Uid);

			Assert.IsTrue(read.Summary.Equals(summaryTextWithoutControlCharacters, StringComparison.OrdinalIgnoreCase));
		}