Esempio n. 1
0
        public void ChecksumChangesTest()
        {
            // Arrange
            DateTimeOffset dto   = DateTimeOffset.UtcNow;
            Note           note1 = new Note();
            Note           note2 = new Note("Some topic here", "Some text here, yes.", dto);
            Note           note3 = new Note("Some topic here", "Some text here, yes.", dto);

            // Act
            string checksum1 = note1.GetChecksumAsHex();
            string checksum2 = note2.GetChecksumAsHex();
            string checksum3 = note3.GetChecksumAsHex();

            string newContent = note3.GetNoteText() + "A";

            note3.UpdateNote(note3.GetNoteTitle(), newContent);
            string checksum4 = note3.GetChecksumAsHex();

            // Assert
            Assert.AreNotEqual(checksum1, checksum2);
            Assert.AreEqual(checksum3, checksum2);
            Assert.AreNotEqual(checksum3, checksum4);
        }
Esempio n. 2
0
        public void ShallowCopyTest()
        {
            // Arrange
            DateTimeOffset dto   = DateTimeOffset.UtcNow;
            Note           note1 = new Note("Some topic here", "Some text here, yes.", dto);

            // Act
            Note note2 = note1.ShallowCopy();

            string checksum1 = note1.GetChecksumAsHex();
            string checksum2 = note2.GetChecksumAsHex();

            // Assert
            Assert.IsNotNull(note2);
            Assert.AreEqual(checksum1, checksum2);
        }
Esempio n. 3
0
        public void ChecksumSurvivesRoundtrip()
        {
            // Arrange
            Note note1 = new Note("Some topic here", "Some text here, yes.");

            // Act
            string checksum1 = note1.GetChecksumAsHex();

            string json = JsonConvert.SerializeObject(note1, Formatting.Indented);

            Note note2 = JsonConvert.DeserializeObject <Note>(json);

            // Assert
            Assert.AreEqual(64, checksum1.Length);
            Assert.AreEqual(checksum1, note2.GetChecksumAsHex());
        }