private void Parse_ValidBasicConfigProperties_ShouldReturnBasicConfig() { var properties = new List <string>(); properties.AddRange(new[] { "class sockets", "{", "maxPacketSize = 1400;", "};", "adapter = -1;", "MaxMsgSend = 128;", "MinErrorToSend = 0.001;", "viewDistance = 2000;", "terrainGrid = 25;" }); var parser = new UniversalParser(); var basicConfig = parser.Parse <BasicConfig>(properties); Assert.NotNull(basicConfig); Assert.Equal(128, basicConfig.MaxMessagesSend); Assert.Equal(1400, basicConfig.MaxPacketSize); Assert.True(Math.Abs(0.001F - basicConfig.MinErrorToSend.Value) < 0.00001); Assert.True(Math.Abs(25F - basicConfig.TerrainGridViewDistance.Value) < 0.00001); Assert.Equal(2000, basicConfig.ObjectViewDistance); }
private void Parse_ValidArmaProfileProperties_ShouldReturnArmaProfile() { var properties = new List <string>(); properties.AddRange(new[] { "class DifficultyPresets", "{", "class CustomDifficulty", "{", "class Options", "{", "groupIndicators = 1", "};", "aiLevelPreset = 2;", "};", "class CustomAiLevel", "{", "skillAI = 0.5;", "precisionAI = 0.5;", "};", "};", "difficulty = \"recruit\";" }); var parser = new UniversalParser(); var armaProfile = parser.Parse <ArmaProfile>(properties); Assert.NotNull(armaProfile); Assert.Equal(1, armaProfile.GroupIndicationType); Assert.Equal(2, armaProfile.AiLevelPreset); Assert.True(Math.Abs(0.5F - armaProfile.AiSkill.Value) < 0.00001); Assert.True(Math.Abs(0.5F - armaProfile.AiPrecision.Value) < 0.00001); Assert.Equal("recruit", armaProfile.DefaultDifficulty.ToLowerInvariant()); }
private void Parse_NullServerConfig_ShouldReturnServerConfig() { var parser = new UniversalParser(); var serverConfig = parser.Parse <ServerConfig>(null); Assert.NotNull(serverConfig); }
private void Parse_NullBasicConfig_ShouldReturnBasicConfig() { var parser = new UniversalParser(); var basicConfig = parser.Parse <BasicConfig>(null); Assert.NotNull(basicConfig); }
private void Parse_Null_ShouldReturnArmaProfile() { var parser = new UniversalParser(); var armaProfile = parser.Parse <ArmaProfile>(null); Assert.NotNull(armaProfile); }
private void Parse_EmptyServerConfigProperties_ShouldReturnServerConfig() { var properties = new List <string>(); var parser = new UniversalParser(); var serverConfig = parser.Parse <ServerConfig>(properties); Assert.NotNull(serverConfig); }
private void Parse_EmptyArmaProfileProperties_ShouldReturnArmaProfile() { var properties = new List <string>(); var parser = new UniversalParser(); var armaProfile = parser.Parse <ArmaProfile>(properties); Assert.NotNull(armaProfile); }
private void Parse_NonValidArmaProfileProperties_ShouldReturnArmaProfile() { var properties = new List <string>(); properties.AddRange(new[] { "groupIndicators = 1;", "wrongProperty = 321213512312213123;" }); var parser = new UniversalParser(); var armaProfile = parser.Parse <ArmaProfile>(properties); Assert.NotNull(armaProfile); Assert.Equal(1, armaProfile.GroupIndicationType); }
private void Parse_ValidServerConfigProperties_ShouldReturnServerConfig() { var properties = new List <string>(); properties.AddRange(new[] { "hostname = \"ыфвфывфыв\";", "loopback = true;", "maxPlayers = 23;", "allowedLoadFileExtensions[] = {", "\"hpp\"", ",\"sqs\"", ",\"sqf\"", "};" }); var parser = new UniversalParser(); var serverConfig = parser.Parse <ServerConfig>(properties); Assert.NotNull(serverConfig); Assert.Equal(23, serverConfig.MaximumAmountOfPlayers); Assert.True(serverConfig.IsLan); Assert.True(new[] { "hpp", "sqs", "sqf" }.SequenceEqual(serverConfig.LoadFileExtensionsWhitelist)); }
private void Parse_WrongObject_ShouldThrowNotSupportedException() { var parser = new UniversalParser(); Assert.Throws <NotSupportedException>(() => parser.Parse <object>(null)); }