示例#1
0
        public void ShallowCopyTest()
        {
            // Arrange
            LoginInformation li1 = new LoginInformation(newTitle: "Random forum", newUrl: "https://somedomain.com", newEmail: "*****@*****.**", newUsername: "******", newPassword: "******");

            LoginInformation li3 = new LoginInformation(newTitle: "Random forum", newUrl: "https://somedomain.com", newEmail: "*****@*****.**", newUsername: "******", newPassword: "******",
                                                        newNotes: "funny dialog is funny", newMFA: "otpauth://totp/DRAGON?secret=SECRET", newIcon: new byte[] { 0, 1, 3, 4, 5, 7 }, newCategory: "forums", newTags: "daily\tmodern");

            // Act
            LoginInformation li2 = li1.ShallowCopy();

            LoginInformation li4 = li3.ShallowCopy();

            string checksum1 = li1.GetChecksumAsHex();
            string checksum2 = li2.GetChecksumAsHex();

            string checksum3 = li3.GetChecksumAsHex();
            string checksum4 = li4.GetChecksumAsHex();

            // Assert
            Assert.IsNotNull(li2);
            Assert.IsNotNull(li4);
            Assert.AreEqual(checksum1, checksum2);
            Assert.AreEqual(checksum3, checksum4);
        }
示例#2
0
        public void ChecksumChangesTest()
        {
            // Arrange
            DateTimeOffset   dto = DateTimeOffset.UtcNow;
            LoginInformation li1 = new LoginInformation();
            LoginInformation li2 = new LoginInformation(newTitle: "Random forum", newUrl: "https://somedomain.com", newEmail: "*****@*****.**", newUsername: "******", newPassword: "******", dto);
            LoginInformation li3 = new LoginInformation(newTitle: "Random forum", newUrl: "https://somedomain.com", newEmail: "*****@*****.**", newUsername: "******", newPassword: "******", dto);

            // Act
            string checksum1 = li1.GetChecksumAsHex();
            string checksum2 = li2.GetChecksumAsHex();
            string checksum3 = li3.GetChecksumAsHex();

            string updatedPassword = li3.GetPassword() + "A";

            li3.UpdatePassword(updatedPassword);
            string checksum4 = li3.GetChecksumAsHex();

            // Assert
            Assert.AreNotEqual(checksum1, checksum2);
            Assert.AreEqual(checksum3, checksum2);
            Assert.AreNotEqual(checksum3, checksum4);
        }
示例#3
0
        public void ChecksumSurvivesRoundtrip()
        {
            // Arrange
            LoginInformation li1 = new LoginInformation(newTitle: "Random forum", newUrl: "https://somedomain.com", newEmail: "*****@*****.**", newUsername: "******", newPassword: "******");

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

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

            LoginInformation li2 = JsonConvert.DeserializeObject <LoginInformation>(json);

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