internal static ITag ParseValue(BinaryReader reader, byte id) { switch (id) { case TagBoolean.TypeId: return(TagBoolean.Parse(reader)); case TagByte.TypeId: return(TagByte.Parse(reader)); case TagShort.TypeId: return(TagShort.Parse(reader)); case TagInt.TypeId: return(TagInt.Parse(reader)); case TagFloat.TypeId: return(TagFloat.Parse(reader)); case TagLong.TypeId: return(TagLong.Parse(reader)); case TagDouble.TypeId: return(TagDouble.Parse(reader)); case TagString.TypeId: return(TagString.Parse(reader)); case TagCompound.TypeId: return(TagCompound.Parse(reader)); case TagList.TypeId: return(TagList.Parse(reader)); default: throw new FormatException("Invalid type ID: " + id + ". At file position " + reader.BaseStream.Position); } }
public override void WritePayload(Stream stream, INamedBinaryTag iTag) { TagInt tag = iTag as TagInt; byte[] data = BitConverter.GetBytes(tag.Value); data = data.ReverseIfLittleEndian(); stream.Write(data, 0, 4); }
public void Indexer_throws_exception_for_tags_not_matching_list_type() { // arrange TagCollection target; target = new TagCollection(TagType.Byte); target.Add(byte.MaxValue); // act target[0] = new TagInt(); }
public void ConstructorTest() { // arrange TagInt tag; int expected; expected = 0; // act tag = new TagInt(); // assert Assert.IsEmpty(tag.Name); Assert.AreEqual(expected, tag.Value); }
public void ConstructorWithValueTest() { // arrange TagInt tag; int value; value = int.MaxValue; // act tag = new TagInt(value); // assert Assert.IsEmpty(tag.Name); Assert.AreEqual(value, tag.Value); }
public void Equals_returns_false_with_different_value() { // arrange TagInt target; TagInt other; bool actual; target = new TagInt(string.Empty, 1073741823); other = new TagInt(string.Empty, 536870911); // act actual = target.Equals(other); // assert Assert.False(actual); }
public void Constructor_sets_name() { // arrange TagInt target; string expected; string actual; expected = "Alphatag"; // act target = new TagInt(expected); // assert actual = target.Name; Assert.Equal(expected, actual); }
public void Equals_returns_false_with_different_name() { // arrange TagInt target; TagInt other; bool actual; target = new TagInt("Alpha", 1073741823); other = new TagInt("Beta", 1073741823); // act actual = target.Equals(other); // assert Assert.False(actual); }
public void Equals_returns_true_for_matching_tag() { // arrange TagInt target; TagInt other; bool actual; target = new TagInt("alpha", 1073741823); other = new TagInt("alpha", 1073741823); // act actual = target.Equals(other); // assert Assert.True(actual); }
public void Constructor_sets_value() { // arrange TagInt target; int expected; int actual; expected = 1073741823; // act target = new TagInt(string.Empty, expected); // assert actual = target.Value; Assert.AreEqual(expected, actual); }
public void Constructor_sets_default_name() { // arrange TagInt target; string expected; string actual; expected = string.Empty; // act target = new TagInt(); // assert actual = target.Name; Assert.Equal(expected, actual); }
public void Indexer_throws_exception_for_tags_not_matching_list_type() { // arrange // ReSharper disable once CollectionNeverQueried.Local var target = new TagCollection(TagType.Byte) { byte.MaxValue }; // act var e = Assert.Throws <ArgumentException>(() => target[0] = new TagInt()); Assert.Equal( $"Only items of type Byte can be added to this collection.{Environment.NewLine}Parameter name: item", e.Message); }
public void Constructor_sets_value_without_name() { // arrange TagInt target; int expected; int actual; expected = 1073741823; // act target = new TagInt(expected); // assert actual = target.Value; Assert.Equal(expected, actual); }
public void Constructor_sets_default_value() { // arrange TagInt target; int expected; int actual; expected = 0; // act target = new TagInt(); // assert actual = target.Value; Assert.Equal(expected, actual); }
public void ToString_returns_string_version_of_tag() { // arrange TagInt target; string expected; string actual; expected = "[Int: gamma=1073741823]"; target = new TagInt("gamma", 1073741823); // act actual = target.ToString(); // assert Assert.Equal(expected, actual); }
public void ToValueString_returns_string_version_of_value() { // arrange TagInt target; string expected; string actual; expected = "1073741823"; target = new TagInt(string.Empty, 1073741823); // act actual = target.ToValueString(); // assert Assert.Equal(expected, actual); }
public void GetHashCode_returns_different_values_with_different_value() { // arrange TagInt target; int actual; int notExpected; target = new TagInt(string.Empty, 1073741823); notExpected = new TagInt(string.Empty, 536870911).GetHashCode(); // act actual = target.GetHashCode(); // assert Assert.NotEqual(notExpected, actual); }
public void ConstructorWithNameAndValueTest() { // arrange TagInt tag; string name; int value; name = "creationDate"; value = int.MaxValue; // act tag = new TagInt(name, value); // assert Assert.AreEqual(name, tag.Name); Assert.AreEqual(value, tag.Value); }
public void GetHashCode_returns_same_value_for_matching_tags() { // arrange TagInt target; int actual; int expected; target = new TagInt("beta", 1073741823); expected = new TagInt("beta", 1073741823).GetHashCode(); // act actual = target.GetHashCode(); // assert Assert.Equal(expected, actual); }
public void ConstructorWithNameTest() { // arrange TagInt tag; string name; int expected; name = "creationDate"; expected = 0; // act tag = new TagInt(name); // assert Assert.AreEqual(name, tag.Name); Assert.AreEqual(expected, tag.Value); }
public void Type_returns_correct_value() { // arrange TagInt target; TagType expected; TagType actual; target = new TagInt(); expected = TagType.Int; // act actual = target.Type; // assert Assert.Equal(expected, actual); }
public void GetHashCode_returns_different_values_with_different_name() { // arrange TagInt target; int actual; int notExpected; target = new TagInt("Alpha", 1073741823); notExpected = new TagInt("Beta", 1073741823).GetHashCode(); // act actual = target.GetHashCode(); // assert Assert.NotEqual(notExpected, actual); }
public void Value_can_be_set() { // arrange TagInt target; int expected; int actual; expected = 1073741823; target = new TagInt(); // act target.Value = expected; // assert actual = target.Value; Assert.Equal(expected, actual); }
public void SetValue_updates_value() { // arrange Tag target; int expected; int actual; target = new TagInt(); expected = 1073741823; // act target.SetValue(expected); // assert actual = ((TagInt)target).Value; Assert.Equal(expected, actual); }
public override object ParsePayload(Stream stream, INamedBinaryTag tagBase) { byte[] data = new byte[4]; if (stream.Read(data, 0, 4) < 4) { throw new EndOfStreamException("End of stream reached inside of tag. Put those bytes back!"); } data = data.ReverseIfLittleEndian(); int val = BitConverter.ToInt32(data, 0); TagInt tag = tagBase as TagInt; if (tag == null) { throw new InvalidCastException("Wrong NBT type! Expected TagInt, found " + tagBase.GetType().Name); } tag.Value = val; return(val); }
private TagBase GetArrayedTag() { CheckCharacter('['); char c0 = NextJsonAt(); NextJsonAt(); SkipWhiteSpace(); if (!InTextLength()) { throw GenerateException("Expected value"); } else if (c0 == 'B') { return(new TagByteArray(CatchArrayItems <byte>(TagType.ByteArray, TagType.Byte, e => { TagByte tag = e as TagByte; return e != null ? tag.Value : (byte)0; }))); } else if (c0 == 'L') { return(new TagLongArray(CatchArrayItems <long>(TagType.LongArray, TagType.Long, e => { TagLong tag = e as TagLong; return e != null ? tag.Value : 0; }))); } else if (c0 == 'I') { return(new TagIntArray(CatchArrayItems <int>(TagType.IntArray, TagType.Int, e => { TagInt tag = e as TagInt; return e != null ? tag.Value : 0; }))); } else { throw GenerateException("Invalid array type '" + c0 + "' found"); } }
public void TestAnvilRegion() { string filename = this.AnvilRegionFileName; FileStream input = File.OpenRead(filename); int[] locations = new int[1024]; byte[] buffer = new byte[4096]; input.Read(buffer, 0, 4096); for (int i = 0; i < 1024; i++) { locations[i] = BitConverter.ToInt32(buffer, i * 4); } int[] timestamps = new int[1024]; input.Read(buffer, 0, 4096); for (int i = 0; i < 1024; i++) { timestamps[i] = BitConverter.ToInt32(buffer, i * 4); } input.Read(buffer, 0, 4); if (BitConverter.IsLittleEndian) { BitHelper.SwapBytes(buffer, 0, 4); } int sizeOfChunkData = BitConverter.ToInt32(buffer, 0) - 1; int compressionType = input.ReadByte(); buffer = new byte[sizeOfChunkData]; input.Read(buffer, 0, sizeOfChunkData); Stream inputStream = null; if (compressionType == 1) { inputStream = new GZipStream(new MemoryStream(buffer), CompressionMode.Decompress); } else if (compressionType == 2) { inputStream = new DeflateStream(new MemoryStream(buffer, 2, buffer.Length - 6), CompressionMode.Decompress); } TagReader reader; reader = new BinaryTagReader(inputStream); TagCompound tag = (TagCompound)reader.ReadTag(); string strTag = tag.ToString(); Assert.IsNotNull(tag); Assert.AreEqual(TagType.Compound, tag.GetTag("Level").Type); TagCompound levelTag = tag.GetCompound("Level"); Tag aTag = levelTag.GetTag("Entities"); Assert.AreEqual(TagType.List, aTag.Type); TagList entitiesTag = aTag as TagList; Assert.AreEqual(0, entitiesTag.Value.Count); aTag = levelTag.GetTag("Biomes"); Assert.AreEqual(TagType.ByteArray, aTag.Type); TagByteArray biomesTag = aTag as TagByteArray; Assert.AreEqual(256, biomesTag.Value.Length); aTag = levelTag.GetTag("LastUpdate"); Assert.AreEqual(TagType.Long, aTag.Type); TagLong lastUpdateTag = aTag as TagLong; Assert.AreEqual(2861877, lastUpdateTag.Value); aTag = levelTag.GetTag("xPos"); Assert.AreEqual(TagType.Int, aTag.Type); TagInt xPosTag = aTag as TagInt; Assert.AreEqual(10, xPosTag.Value); aTag = levelTag.GetTag("zPos"); Assert.AreEqual(TagType.Int, aTag.Type); TagInt zPosTag = aTag as TagInt; Assert.AreEqual(0, zPosTag.Value); aTag = levelTag.GetTag("TileEntities"); Assert.AreEqual(TagType.List, aTag.Type); TagList tileEntitiesTag = aTag as TagList; Assert.AreEqual(0, tileEntitiesTag.Value.Count); aTag = levelTag.GetTag("TerrainPopulated"); Assert.AreEqual(TagType.Byte, aTag.Type); TagByte terrainPopulatedTag = aTag as TagByte; Assert.AreEqual(1, terrainPopulatedTag.Value); aTag = levelTag.GetTag("HeightMap"); Assert.AreEqual(TagType.IntArray, aTag.Type); TagIntArray heightmapTag = aTag as TagIntArray; Assert.AreEqual(256, heightmapTag.Value.Length); aTag = levelTag.GetTag("Sections"); Assert.AreEqual(TagType.List, aTag.Type); TagList sectionsTag = aTag as TagList; Assert.AreEqual(4, sectionsTag.Value.Count); TagCompound section_0 = sectionsTag.Value[0] as TagCompound; Assert.IsNotNull(section_0); TagByteArray section_0_data = section_0.GetByteArray("Data"); Assert.IsNotNull(section_0_data); Assert.AreEqual(2048, section_0_data.Value.Length); TagByteArray section_0_skyLight = section_0.GetByteArray("SkyLight"); Assert.IsNotNull(section_0_skyLight); Assert.AreEqual(2048, section_0_skyLight.Value.Length); TagByteArray section_0_blockLight = section_0.GetByteArray("BlockLight"); Assert.IsNotNull(section_0_blockLight); Assert.AreEqual(2048, section_0_blockLight.Value.Length); TagByte section_0_y = section_0.GetByte("Y"); Assert.IsNotNull(section_0_y); Assert.AreEqual(0, section_0_y.Value); TagByteArray section_0_blocks = section_0.GetByteArray("Blocks"); Assert.IsNotNull(section_0_blocks); Assert.AreEqual(4096, section_0_blocks.Value.Length); TagCompound section_1 = sectionsTag.Value[1] as TagCompound; Assert.IsNotNull(section_1); TagByteArray section_1_data = section_1.GetByteArray("Data"); Assert.IsNotNull(section_1_data); Assert.AreEqual(2048, section_1_data.Value.Length); TagByteArray section_1_skyLight = section_1.GetByteArray("SkyLight"); Assert.IsNotNull(section_1_skyLight); Assert.AreEqual(2048, section_1_skyLight.Value.Length); TagByteArray section_1_blockLight = section_1.GetByteArray("BlockLight"); Assert.IsNotNull(section_1_blockLight); Assert.AreEqual(2048, section_1_blockLight.Value.Length); TagByte section_1_y = section_1.GetByte("Y"); Assert.IsNotNull(section_1_y); Assert.AreEqual(1, section_1_y.Value); TagByteArray section_1_blocks = section_1.GetByteArray("Blocks"); Assert.IsNotNull(section_1_blocks); Assert.AreEqual(4096, section_1_blocks.Value.Length); TagCompound section_2 = sectionsTag.Value[2] as TagCompound; Assert.IsNotNull(section_2); TagByteArray section_2_data = section_2.GetByteArray("Data"); Assert.IsNotNull(section_2_data); Assert.AreEqual(2048, section_2_data.Value.Length); TagByteArray section_2_skyLight = section_2.GetByteArray("SkyLight"); Assert.IsNotNull(section_2_skyLight); Assert.AreEqual(2048, section_2_skyLight.Value.Length); TagByteArray section_2_blockLight = section_2.GetByteArray("BlockLight"); Assert.IsNotNull(section_2_blockLight); Assert.AreEqual(2048, section_2_blockLight.Value.Length); TagByte section_2_y = section_2.GetByte("Y"); Assert.IsNotNull(section_2_y); Assert.AreEqual(2, section_2_y.Value); TagByteArray section_2_blocks = section_2.GetByteArray("Blocks"); Assert.IsNotNull(section_2_blocks); Assert.AreEqual(4096, section_2_blocks.Value.Length); TagCompound section_3 = sectionsTag.Value[3] as TagCompound; Assert.IsNotNull(section_3); TagByteArray section_3_data = section_3.GetByteArray("Data"); Assert.IsNotNull(section_3_data); Assert.AreEqual(2048, section_3_data.Value.Length); TagByteArray section_3_skyLight = section_3.GetByteArray("SkyLight"); Assert.IsNotNull(section_3_skyLight); Assert.AreEqual(2048, section_3_skyLight.Value.Length); TagByteArray section_3_blockLight = section_3.GetByteArray("BlockLight"); Assert.IsNotNull(section_3_blockLight); Assert.AreEqual(2048, section_3_blockLight.Value.Length); TagByte section_3_y = section_3.GetByte("Y"); Assert.IsNotNull(section_3_y); Assert.AreEqual(3, section_3_y.Value); TagByteArray section_3_blocks = section_3.GetByteArray("Blocks"); Assert.IsNotNull(section_3_blocks); Assert.AreEqual(4096, section_3_blocks.Value.Length); }
public void TestLoadComplexNbt() { Tag tag; tag = this.CreateComplexData(); Assert.IsNotNull(tag); Assert.IsInstanceOf <TagCompound>(tag); TagCompound level = tag as TagCompound; Assert.AreEqual("Level", level.Name); TagShort shortTest = level.GetShort("shortTest"); Assert.IsNotNull(shortTest); Assert.AreEqual("shortTest", shortTest.Name); Assert.AreEqual(32767, shortTest.Value); TagLong longTest = level.GetLong("longTest"); Assert.IsNotNull(longTest); Assert.AreEqual("longTest", longTest.Name); Assert.AreEqual(9223372036854775807, longTest.Value); TagFloat floatTest = level.GetFloat("floatTest"); Assert.IsNotNull(floatTest); Assert.AreEqual("floatTest", floatTest.Name); Assert.AreEqual(0.49823147f, floatTest.Value); TagString stringTest = level.GetString("stringTest"); Assert.IsNotNull(stringTest); Assert.AreEqual("stringTest", stringTest.Name); Assert.AreEqual("HELLO WORLD THIS IS A TEST STRING едж!", stringTest.Value); TagInt intTest = level.GetInt("intTest"); Assert.IsNotNull(intTest); Assert.AreEqual("intTest", intTest.Name); Assert.AreEqual(2147483647, intTest.Value); TagCompound nestedCompoundTest = level.GetCompound("nested compound test"); Assert.IsNotNull(nestedCompoundTest); Assert.AreEqual("nested compound test", nestedCompoundTest.Name); TagCompound ham = nestedCompoundTest.GetCompound("ham"); Assert.IsNotNull(ham); Assert.AreEqual("ham", ham.Name); TagString ham_name = ham.GetString("name"); Assert.IsNotNull(ham_name); Assert.AreEqual("name", ham_name.Name); Assert.AreEqual("Hampus", ham_name.Value); TagFloat ham_value = ham.GetFloat("value"); Assert.IsNotNull(ham_value); Assert.AreEqual("value", ham_value.Name); Assert.AreEqual(0.75f, ham_value.Value); TagCompound egg = nestedCompoundTest.GetCompound("egg"); Assert.IsNotNull(egg); Assert.AreEqual("egg", egg.Name); TagString egg_name = egg.GetString("name"); Assert.IsNotNull(egg_name); Assert.AreEqual("name", egg_name.Name); Assert.AreEqual("Eggbert", egg_name.Value); TagFloat egg_value = egg.GetFloat("value"); Assert.IsNotNull(egg_value); Assert.AreEqual("value", egg_value.Name); Assert.AreEqual(0.5f, egg_value.Value); TagByte byteTest = level.GetByte("byteTest"); Assert.IsNotNull(byteTest); Assert.AreEqual("byteTest", byteTest.Name); Assert.AreEqual(0x7f, byteTest.Value); TagDouble doubleTest = level.GetDouble("doubleTest"); Assert.IsNotNull(doubleTest); Assert.AreEqual("doubleTest", doubleTest.Name); Assert.AreEqual(0.4931287132182315, doubleTest.Value); TagList listTest_long = level.GetList("listTest (long)"); Assert.IsNotNull(listTest_long); Assert.AreEqual("listTest (long)", listTest_long.Name); Assert.IsNotNull(listTest_long.Value); Assert.AreEqual(5, listTest_long.Value.Count); Assert.AreEqual(11, (listTest_long.Value[0] as TagLong).Value); Assert.AreEqual(12, (listTest_long.Value[1] as TagLong).Value); Assert.AreEqual(13, (listTest_long.Value[2] as TagLong).Value); Assert.AreEqual(14, (listTest_long.Value[3] as TagLong).Value); Assert.AreEqual(15, (listTest_long.Value[4] as TagLong).Value); TagList listTest_compound = level.GetList("listTest (compound)"); Assert.IsNotNull(listTest_compound); Assert.AreEqual("listTest (compound)", listTest_compound.Name); Assert.IsNotNull(listTest_compound.Value); Assert.AreEqual(2, listTest_compound.Value.Count); TagCompound listTest_compound_tag0 = listTest_compound.Value[0] as TagCompound; Assert.IsNotNull(listTest_compound_tag0); TagString listTest_compound_tag0_name = listTest_compound_tag0.GetString("name"); Assert.IsNotNull(listTest_compound_tag0_name); Assert.AreEqual("name", listTest_compound_tag0_name.Name); Assert.AreEqual("Compound tag #0", listTest_compound_tag0_name.Value); TagLong listTest_compound_tag0_createdOn = listTest_compound_tag0.GetLong("created-on"); Assert.IsNotNull(listTest_compound_tag0_createdOn); Assert.AreEqual("created-on", listTest_compound_tag0_createdOn.Name); Assert.AreEqual(1264099775885, listTest_compound_tag0_createdOn.Value); TagCompound listTest_compound_tag1 = listTest_compound.Value[1] as TagCompound; Assert.IsNotNull(listTest_compound_tag1); TagString listTest_compound_tag1_name = listTest_compound_tag1.GetString("name"); Assert.IsNotNull(listTest_compound_tag1_name); Assert.AreEqual("name", listTest_compound_tag1_name.Name); Assert.AreEqual("Compound tag #1", listTest_compound_tag1_name.Value); TagLong listTest_compound_tag1_createdOn = listTest_compound_tag1.GetLong("created-on"); Assert.IsNotNull(listTest_compound_tag1_createdOn); Assert.AreEqual("created-on", listTest_compound_tag1_createdOn.Name); Assert.AreEqual(1264099775885, listTest_compound_tag1_createdOn.Value); TagByteArray byteArrayTest = level.GetByteArray("byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))"); Assert.IsNotNull(byteArrayTest); Assert.AreEqual("byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))", byteArrayTest.Name); Assert.IsNotNull(byteArrayTest.Value); Assert.AreEqual(1000, byteArrayTest.Value.Length); }
public Tag ExportTag() { tc ["SleepTimer"] = new TagShort(SleepTimer); TagList<TagDouble > motion = new TagList<TagDouble>(); motion [0] = new TagDouble(Motion [0]); motion [1] = new TagDouble(Motion [1]); motion [2] = new TagDouble(Motion [2]); tc ["Motion"] = motion; tc ["OnGround"] = new TagByte(){Byte = OnGround}; tc ["HurtTime"] = new TagShort(HurtTime); tc ["Health"] = new TagShort(Health); tc ["Dimension"] = new TagInt(Dimension); tc ["Air"] = new TagShort(Air); if (tc ["Inventory"] is TagList<TagCompound> == false) { tc ["Inventory"] = new TagList<TagCompound>(); } TagList<TagCompound > inv = tc ["Inventory"] as TagList<TagCompound>; for (byte n = 0; n < 104; n++) { SlotItem item = null; if (n < 36) item = Inventory [n]; if (n >= 80 && n < 84) item = InventoryCraft [n - 80]; if (n >= 100) item = InventoryWear [n - 100]; TagCompound ti = null; //Find slot item foreach (TagCompound itc in inv) { if (itc ["Slot"].Byte == n) { ti = itc; break; } } if (item == null) { if (ti != null) inv.Remove(ti); continue; } if (ti == null) { ti = new TagCompound(); inv.Add(ti); } ti ["id"] = new TagShort((short)item.ItemID); ti ["Damage"] = new TagShort((short)item.Uses); ti ["Count"] = new TagByte((byte)item.Count); ti ["Slot"] = new TagByte(n); } inv.Sort((x, y) => x ["Slot"].Byte - y ["Slot"].Byte); TagList<TagDouble > p = new TagList<TagDouble>(); p [0] = new TagDouble(Pos .X); p [1] = new TagDouble(Pos .Y); p [2] = new TagDouble(Pos .Z); tc ["Pos"] = p; tc ["AttackTime"] = new TagShort(AttackTime); tc ["Sleeping"] = new TagByte(Sleeping); tc ["Fire"] = new TagShort(Fire); tc ["FallDistance"] = new TagFloat(FallDistance); TagList<TagFloat > rot = new TagList<TagFloat>(); rot [0] = new TagFloat(Rotation [0]); rot [1] = new TagFloat(Rotation [1]); tc ["Rotation"] = rot; tc ["DeathTime"] = new TagShort(DeathTime); if (Spawn != null) { tc ["SpawnX"] = new TagInt(Spawn.X); tc ["SpawnY"] = new TagInt(Spawn.Y); tc ["SpawnZ"] = new TagInt(Spawn.Z); } tc ["foodExhaustionLevel"] = new TagFloat(foodExhaustionLevel); tc ["foodTickTimer"] = new TagInt(foodTickTimer); tc ["foodSaturationLevel"] = new TagFloat(foodSaturationLevel); tc ["foodLevel"] = new TagInt(foodLevel); tc ["XpLevel"] = new TagInt(XpLevel); tc ["XpTotal"] = new TagInt(XpTotal); tc ["Xp"] = new TagInt(Xp); tc ["playerGameType"] = new TagInt(playerGameType); return tc; }
public void ToStringTest() { // arrange TagInt target; string expected; string actual; string name; int value; name = "tagname"; value = int.MaxValue; expected = string.Format("[Int: {0}={1}]", name, value); target = new TagInt(name, value); // act actual = target.ToString(); // assert Assert.AreEqual(expected, actual); }
public void NameTest() { // arrange TagInt target; string expected; target = new TagInt(); expected = "newvalue"; // act target.Name = expected; // assert Assert.AreEqual(expected, target.Name); }
public void ValueTest() { // arrange TagInt target; int expected; target = new TagInt(); expected = int.MaxValue; // act target.Value = expected; // assert Assert.AreEqual(expected, target.Value); }
public void TypeTest() { // arrange TagType expected; TagType actual; expected = TagType.Int; // act actual = new TagInt().Type; // assert Assert.AreEqual(expected, actual); }
public void ToStringWithIndentTest() { // arrange TagInt target; string expected; string actual; string name; int value; string prefix; prefix = "test"; name = "tagname"; value = int.MaxValue; expected = string.Format("{2}[Int: {0}={1}]", name, value, prefix); target = new TagInt(name, value); // act actual = target.ToString(prefix); // assert Assert.AreEqual(expected, actual); }
public void ToValueStringTest() { // arrange ITag target; string expected; string actual; int value; value = int.MaxValue; expected = value.ToString(CultureInfo.InvariantCulture); target = new TagInt(value); // act actual = target.ToValueString(); // assert Assert.AreEqual(expected, actual); }