public void UnitTestEvaluateTwoChecksMethod() { string currentDirectory = (Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()))) + @"\Comparer\bin\Debug"); List <FromFileToStruct.Product> currentCheck = new List <FromFileToStruct.Product>(); List <FromFileToStruct.Product> fullDatabase = new List <FromFileToStruct.Product>(); fullDatabase = FromFileToStruct.MakeProductList2(currentDirectory + "\\FullDatabase.txt"); var maxima = from a in fullDatabase where a.shop == "maxima" select a; var rimi = from a in fullDatabase where a.shop == "rimi" select a; currentCheck = FromFileToStruct.MakeProductList(currentDirectory + "\\TempResult.txt"); WriteToFile write = new WriteToFile(); string infoFile = write.Write(currentDirectory, 1); float expectedMin = -1000; float expectedMax = 1000; Comparer.CompareShops x = new Comparer.CompareShops(); float actual = x.EvaluateTwoChecks(currentCheck, maxima, write, infoFile); Assert.IsTrue(actual >= expectedMin && actual <= expectedMax); }
public void UnitTestFormatFloatMethod() { float expected = 10.6f; float actual = FromFileToStruct.formatFloat(10.598f); Assert.AreEqual(expected, actual); }
public IHttpActionResult CompareShops([FromBody] string receivedString) { float spent = 0; CompareShops x = new CompareShops(new WriteToFile()); List <FromFileToStruct.Product> curr = FromFileToStruct.MakeProductList(receivedString); foreach (FromFileToStruct.Product abc in curr) { spent += abc.price; } string a = x.CompareResults(curr); UpdateDababase.UpdateDatabase(curr); return(Ok(spent + "#" + a)); }