Example #1
0
        public void TestGetSampleDevice()
        {
            var randomnumber = new Random();
            ISecurityKeyGenerator securityKeyGenerator = new SecurityKeyGenerator();
            var keys = securityKeyGenerator.CreateRandomKeys();
            var d    = SampleDeviceFactory.GetSampleDevice(randomnumber, keys);

            Assert.NotNull(d);
            Assert.NotNull(d.DeviceProperties);
            Assert.NotNull(d.DeviceProperties.DeviceID);
        }
        public void CreateRandomKeysTest()
        {
            ISecurityKeyGenerator securityKeyGenerator = new SecurityKeyGenerator();
            var keys1 = securityKeyGenerator.CreateRandomKeys();
            var keys2 = securityKeyGenerator.CreateRandomKeys();

            Assert.NotNull(keys1);
            Assert.NotEqual(keys1.PrimaryKey, keys1.SecondaryKey);
            Assert.NotEqual(keys1.PrimaryKey, keys2.PrimaryKey);
            Assert.NotEqual(keys1.SecondaryKey, keys2.SecondaryKey);
        }
        public User Login(string userName, string password)
        {
            User user;

            if (!Users.TryGetValue(userName, out user))
            {
                throw new UserNotFoundException("User name: " + userName + " not found, please check for typing mistakes.");
            }

            if (!user.Password.Equals(password))
            {
                throw new IncorrectPasswordException("Incorrect password entered. Please try again");
            }

            user.Connect(SecurityKeyGenerator.Next());

            return(user);
        }