コード例 #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);
        }
コード例 #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));
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #5
0
        public void CreateTag_throws_exception_for_invalid_type()
        {
            // arrange
            TagType type;

            type = (TagType)(-1);

            // act
            TagFactory.CreateTag(type);
        }
コード例 #6
0
ファイル: ArduinoNFC.cs プロジェクト: drake1011/LegoCrypto
        private ITag WaitRead(ArduinoDriver arduino)
        {
            var output = WaitForNtagHere(arduino);

            if (output == ArduinoCommands.NTAG_FOUND)
            {
                return(NtagRead(arduino));
            }
            return((ITag)TagFactory.CreateTag());
        }
コード例 #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]);
        }
コード例 #8
0
ファイル: TagFactoryTesting.cs プロジェクト: Morr0/Atheer
        public void ShouldCreateTag()
        {
            string title      = "Hello";
            string expectedId = "hello";

            var tag = _factory.CreateTag(title);

            Assert.Equal(expectedId, tag.Id);
            Assert.Equal(title, tag.Title);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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]);
        }
コード例 #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());
        }
コード例 #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());
        }
コード例 #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());
        }
コード例 #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());
        }
コード例 #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());
        }
コード例 #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());
        }
コード例 #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]);
        }
コード例 #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());
        }
コード例 #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]);
        }
コード例 #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());
        }
コード例 #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);
        }
コード例 #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]);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #29
0
ファイル: ArduinoNFC.cs プロジェクト: drake1011/LegoCrypto
        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));
        }
コード例 #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);
        }