public void TestNullStuff() { string result = BoEdiMapper.ToEdi("Landescode", null); Assert.IsNull(result); result = BoEdiMapper.ToEdi("Rollencodetyp", "0"); Assert.IsNull(result); }
public void TestSimpleEnums() { foreach (string objectName in expectedResults.Keys) { Dictionary <string, string> map = expectedResults[objectName]; foreach (string teststring in map.Keys) { string expectedResult = map[teststring]; string result = BoEdiMapper.ToEdi(objectName, teststring); Assert.AreEqual(expectedResult, result); } } }
public void TestSimpleEnums() { foreach (string objectName in expectedResults.Keys) { Dictionary <string, string> map = expectedResults[objectName]; foreach (string teststring in map.Keys) { string expectedResult = map[teststring]; //BO4E.StaticLogger.Logger = new Microsoft.Extensions.Logging.Debug.DebugLogger("Testlogger", (log, level) => { return true; }); string result = BoEdiMapper.ToEdi(objectName, teststring); Assert.AreEqual(expectedResult, result); } } }
public void TestBoEdiReplacement() { string[] files = Directory.GetFiles($"BoEdiMapper/", "*.json"); foreach (string file in files) { JObject json; using (StreamReader r = new StreamReader(file)) { string jsonString = r.ReadToEnd(); json = JsonConvert.DeserializeObject <JObject>(jsonString); } Assert.IsNotNull(json["input"], $"You have to specify an 'input' in test file {file}"); Assert.IsNotNull(json["expectedResult"], $"You have to specify an 'expectedOutput' in test file {file}"); BusinessObject bo; try { bo = JsonConvert.DeserializeObject <BusinessObject>(json["input"].ToString()); } catch (ArgumentException) { bo = BoMapper.MapObject(json["input"]["boTyp"].ToString(), (JObject)json["input"]); } JObject result = BoEdiMapper.ReplaceWithEdiValues(bo); //JObject result = JsonConvert.DeserializeObject<JObject>(JsonConvert.SerializeObject(, new StringEnumConverter())); var jdp = new JsonDiffPatch(); var left = JsonHelper.RemoveEmptyChildren(json["expectedResult"]); var right = JsonHelper.RemoveEmptyChildren(result); var patch = jdp.Diff(left, right); string additionalMessage = string.Empty; if (patch != null) { additionalMessage = $";\r\n Diff: { patch.ToString()}"; } try { Assert.IsNull(patch, additionalMessage); } catch (AssertFailedException) when(patch != null && additionalMessage.Contains("HGAS") && additionalMessage.Contains("H_GAS")) { } } }