Esempio n. 1
0
        public void Test_CreateTag_Vehicle_id_uid_Pass()
        {
            var tag = TagFactory.CreateTag(id: _token_id, uid: _uid);

            //verify the correct implementation was created
            Assert.Equal(tag.GetType().Name, _vehicleTagImpl);
            Assert.Equal(_uid, tag.UID);
            Assert.Equal(_token_id, tag.ID);
        }
Esempio n. 2
0
        public void Test_CreateTag_validate_UID_Not_Valid_Length_Fail()
        {
            const string nibble = "A";

            // too short
            Assert.Throws <ArgumentException>(() => TagFactory.CreateTag(id: _char_id, uid: nibble));
            // too long
            Assert.Throws <ArgumentException>(() => TagFactory.CreateTag(id: _char_id, uid: _uid + nibble));
        }
Esempio n. 3
0
        public void Test_CreateTag_Character_id_uid_Pass()
        {
            var tag = TagFactory.CreateTag(id: _char_id, uid: _uid);

            //verify the correct implementation was created
            Assert.Equal(tag.GetType().Name, _charTagImpl);
            Assert.Equal(_uid, tag.UID);
            Assert.Equal(_char_id, tag.ID);
        }
Esempio n. 4
0
        public void CreateTag_with_value_throws_exception_for_invalid_type()
        {
            // arrange
            TagType type;

            type = (TagType)(-1);

            // act
            TagFactory.CreateTag(string.Empty, type, 13);
        }
Esempio n. 5
0
        public void CreateTag_throws_exception_for_invalid_type()
        {
            // arrange
            TagType type;

            type = (TagType)(-1);

            // act
            TagFactory.CreateTag(type);
        }
Esempio n. 6
0
        private ITag WaitRead(ArduinoDriver arduino)
        {
            var output = WaitForNtagHere(arduino);

            if (output == ArduinoCommands.NTAG_FOUND)
            {
                return(NtagRead(arduino));
            }
            return((ITag)TagFactory.CreateTag());
        }
Esempio n. 7
0
        public void Test_Decrypt_Token_id_Pass()
        {
            var tag = TagFactory.CreateTag(id: _token_id, uid: _uid);

            tag.Decrypt();

            Assert.Equal(_uid, tag.UID);
            Assert.Equal(_token_id, tag.ID);
            Assert.Equal(_pwd, tag.Pages[DataRegister.Page43]);
        }
Esempio n. 8
0
        public void ShouldCreateTag()
        {
            string title      = "Hello";
            string expectedId = "hello";

            var tag = _factory.CreateTag(title);

            Assert.Equal(expectedId, tag.Id);
            Assert.Equal(title, tag.Title);
        }
Esempio n. 9
0
        public void CreateTag_with_list_type_for_non_list_throws_exception()
        {
            // arrange
            const TagType type     = TagType.Byte;
            const TagType listType = TagType.ByteArray;

            // act
            var e = Assert.Throws <ArgumentException>(() => TagFactory.CreateTag(string.Empty, type, listType));

            Assert.Equal($"Only lists can have a list type.{Environment.NewLine}Parameter name: listType", e.Message);
        }
Esempio n. 10
0
        public void CreateTag_with_value_throws_exception_for_invalid_type()
        {
            // arrange
            const TagType type = (TagType)(-1);

            // act
            var e = Assert.Throws <ArgumentException>(() => TagFactory.CreateTag(string.Empty, type, 13));

            Assert.Equal($"Unrecognized or unsupported tag type.{Environment.NewLine}Parameter name: tagType",
                         e.Message);
        }
Esempio n. 11
0
        public void CreateTag_with_list_type_for_non_list_throws_exception()
        {
            // arrange
            TagType type;
            TagType listType;

            type     = TagType.Byte;
            listType = TagType.ByteArray;

            // act
            TagFactory.CreateTag(string.Empty, type, listType);
        }
Esempio n. 12
0
        public void CreateTag_creates_list()
        {
            // arrange
            const TagType type     = TagType.List;
            const TagType listType = TagType.Byte;

            // act
            var actual = TagFactory.CreateTag(type, listType);

            // assert
            Assert.NotNull(actual);
            Assert.Equal(listType, actual.ListType);
        }
Esempio n. 13
0
        public void Test_CreateTag_Token_data_Pass()
        {
            var tag = TagFactory.CreateTag(data: _uid + _vehicle_page35 + _vehicle_page36 + _vehicle_page37 + _vehicle_page38);

            //verify the correct implementation was created
            Assert.Equal(tag.GetType().Name, _vehicleTagImpl);
            Assert.Equal(_uid, tag.UID);
            Assert.Equal(_token_id, tag.ID);
            Assert.Equal(_vehicle_page35, tag.Pages[DataRegister.Page35]);
            Assert.Equal(_vehicle_page36, tag.Pages[DataRegister.Page36]);
            Assert.Equal(_vehicle_page37, tag.Pages[DataRegister.Page37]);
            Assert.Equal(_vehicle_page38, tag.Pages[DataRegister.Page38]);
        }
Esempio n. 14
0
        public void Create_with_value_sets_int_value()
        {
            // arrange
            Tag actual;
            int expected;

            expected = 1073741823;

            // act
            actual = TagFactory.CreateTag(expected);

            // assert
            Assert.Equal(expected, actual.GetValue());
        }
Esempio n. 15
0
        public void Create_with_value_sets_string_value()
        {
            // arrange
            Tag    actual;
            string expected;

            expected = "HELLO WORLD THIS IS A TEST STRING ÅÄÖ!";

            // act
            actual = TagFactory.CreateTag(expected);

            // assert
            Assert.Equal(expected, actual.GetValue());
        }
Esempio n. 16
0
        public void Create_with_value_sets_double_value()
        {
            // arrange
            Tag    actual;
            double expected;

            expected = 8.98846567431158E+307;

            // act
            actual = TagFactory.CreateTag(expected);

            // assert
            Assert.Equal(expected, actual.GetValue());
        }
Esempio n. 17
0
        public void Create_with_value_sets_float_value()
        {
            // arrange
            Tag   actual;
            float expected;

            expected = 1.701412E+38F;

            // act
            actual = TagFactory.CreateTag(expected);

            // assert
            Assert.Equal(expected, actual.GetValue());
        }
Esempio n. 18
0
        public void Create_with_value_sets_short_value()
        {
            // arrange
            Tag   actual;
            short expected;

            expected = (short)(short.MaxValue >> 1);

            // act
            actual = TagFactory.CreateTag(expected);

            // assert
            Assert.Equal(expected, actual.GetValue());
        }
Esempio n. 19
0
        public void Create_with_value_sets_byte_value()
        {
            // arrange
            Tag  actual;
            byte expected;

            expected = (byte)(byte.MaxValue >> 1);

            // act
            actual = TagFactory.CreateTag(expected);

            // assert
            Assert.Equal(expected, actual.GetValue());
        }
Esempio n. 20
0
        public void Test_Decrypt_Token_data_Pass()
        {
            var tag = TagFactory.CreateTag(data: _uid + _vehicle_page35 + _vehicle_page36 + _vehicle_page37 + _vehicle_page38);

            tag.Decrypt();

            Assert.Equal(_uid, tag.UID);
            Assert.Equal(_token_id, tag.ID);
            Assert.Equal(_vehicle_page35, tag.Pages[DataRegister.Page35]);
            Assert.Equal(_vehicle_page36, tag.Pages[DataRegister.Page36]);
            Assert.Equal(_vehicle_page37, tag.Pages[DataRegister.Page37]);
            Assert.Equal(_vehicle_page38, tag.Pages[DataRegister.Page38]);
            Assert.Equal(_pwd, tag.Pages[DataRegister.Page43]);
        }
Esempio n. 21
0
        public void Create_with_value_sets_long_value()
        {
            // arrange
            Tag  actual;
            long expected;

            expected = 4611686018427387903;

            // act
            actual = TagFactory.CreateTag(expected);

            // assert
            Assert.Equal(expected, actual.GetValue());
        }
Esempio n. 22
0
        public void Test_Encrypt_Character_Pass()
        {
            var tag = TagFactory.CreateTag(id: _char_id, uid: _uid);

            tag.Encrypt();

            Assert.Equal(_uid, tag.UID);
            Assert.Equal(_char_id, tag.ID);
            Assert.Equal(_char_page35, tag.Pages[DataRegister.Page35]);
            Assert.Equal(_char_page36, tag.Pages[DataRegister.Page36]);
            Assert.Equal(_char_page37, tag.Pages[DataRegister.Page37]);
            Assert.Equal(_char_page38, tag.Pages[DataRegister.Page38]);
            Assert.Equal(_pwd, tag.Pages[DataRegister.Page43]);
        }
Esempio n. 23
0
        public void Create_with_value_sets_bytearray_value()
        {
            // arrange
            Tag actual;

            byte[] expected;

            expected = new byte[] { 2, 4, 8, 16, 32, 64, 128 };

            // act
            actual = TagFactory.CreateTag(expected);

            // assert
            Assert.Equal(expected, actual.GetValue());
        }
Esempio n. 24
0
        public void Create_with_type_creates_bytearray()
        {
            // arrange
            Tag     actual;
            TagType type;

            type = TagType.ByteArray;

            // act
            actual = TagFactory.CreateTag(type);

            // assert
            Assert.NotNull(actual);
            Assert.IsType <TagByteArray>(actual);
        }
Esempio n. 25
0
        public void Test_CreateTag_Character_data_Pass()
        {
            var tag = TagFactory.CreateTag(data: _uid + _char_page35 + _char_page36 + _char_page37 + _char_page38);

            //verify the correct implementation was created
            var test = tag.GetType();

            Assert.Equal(tag.GetType().Name, _charTagImpl);
            Assert.Equal(_uid, tag.UID);
            Assert.Equal(_char_id, tag.ID);
            Assert.Equal(_char_page35, tag.Pages[DataRegister.Page35]);
            Assert.Equal(_char_page36, tag.Pages[DataRegister.Page36]);
            Assert.Equal(_char_page37, tag.Pages[DataRegister.Page37]);
            Assert.Equal(_char_page38, tag.Pages[DataRegister.Page38]);
        }
Esempio n. 26
0
        public void Create_with_value_creates_string_type()
        {
            // arrange
            Tag    actual;
            string expected;

            expected = "HELLO WORLD THIS IS A TEST STRING ÅÄÖ!";

            // act
            actual = TagFactory.CreateTag(expected);

            // assert
            Assert.NotNull(actual);
            Assert.IsType <TagString>(actual);
        }
Esempio n. 27
0
        public void Create_with_value_creates_byte_type()
        {
            // arrange
            Tag  actual;
            byte expected;

            expected = (byte)(byte.MaxValue >> 1);

            // act
            actual = TagFactory.CreateTag(expected);

            // assert
            Assert.NotNull(actual);
            Assert.IsType <TagByte>(actual);
        }
Esempio n. 28
0
        public void Create_with_type_creates_list()
        {
            // arrange
            Tag     actual;
            TagType type;

            type = TagType.List;

            // act
            actual = TagFactory.CreateTag(type);

            // assert
            Assert.NotNull(actual);
            Assert.IsType <TagList>(actual);
        }
Esempio n. 29
0
        private ITag NtagRead(ArduinoDriver arduino)
        {
            var result = string.Empty;

            result = arduino.SendCommand(ArduinoCommands.NTAG_FULL);
            string[] SplitResult = result.Split('/', ' ');

            if (SplitResult.Length > 1)
            {
                Console.WriteLine(result);
                return(WaitRead(arduino));
            }

            return(TagFactory.CreateTag(result));
        }
Esempio n. 30
0
        public void Create_with_type_creates_string()
        {
            // arrange
            Tag     actual;
            TagType type;

            type = TagType.String;

            // act
            actual = TagFactory.CreateTag(type);

            // assert
            Assert.NotNull(actual);
            Assert.IsType <TagString>(actual);
        }