/// <summary> /// Send the data of the test to the server. /// </summary> /// <param name="testResultImage">The image to send.</param> public static bool SendImage(TestResultImage testResultImage) { if (!Connect()) { throw new InvalidOperationException("Could not connect to image comparer server"); } try { if (testResultImage.TestName == null && NUnit.Framework.TestContext.CurrentContext != null) { testResultImage.TestName = NUnit.Framework.TestContext.CurrentContext.Test.FullName; } var binaryWriter = new BinaryWriter(ImageComparisonServer.WriteStream); var binaryReader = new BinaryReader(ImageComparisonServer.ReadStream); // Header binaryWriter.Write((int)ImageServerMessageType.SendImage); GameTestBase.TestGameLogger.Info(@"Sending image information..."); testResultImage.Write(binaryWriter); return(binaryReader.ReadBoolean()); } catch (Exception) { return(false); } }
/// <summary> /// Send the data of the test to the server. /// </summary> /// <param name="testResultImage">The image to send.</param> public static bool SendImage(TestResultImage testResultImage) { var task = SendImageAsync(testResultImage); task.Wait(); return(task.Result); }
/// <summary> /// Send the data of the test to the server. /// </summary> /// <param name="testResultImage">The image to send.</param> public static async Task <bool> SendImageAsync(TestResultImage testResultImage) { if (!Connect()) { throw new InvalidOperationException("Could not connect to image comparer server"); } try { if (testResultImage.TestName == null && NUnit.Framework.TestContext.CurrentContext != null) { testResultImage.TestName = NUnit.Framework.TestContext.CurrentContext.Test.FullName; } // Send initial parameters using (var memoryStream = new MemoryStream()) { var binaryWriter = new BinaryWriter(memoryStream); // Header binaryWriter.Write((int)ImageServerMessageType.SendImage); GameTestBase.TestGameLogger.Info(@"Sending image information..."); testResultImage.Write(binaryWriter); var dataWriter = new DataWriter(imageComparisonServer.OutputStream); dataWriter.WriteBytes(memoryStream.ToArray()); await dataWriter.StoreAsync(); await dataWriter.FlushAsync(); dataWriter.DetachStream(); } var dataReader = new DataReader(imageComparisonServer.InputStream); await dataReader.LoadAsync(1); var result = dataReader.ReadBoolean(); dataReader.DetachStream(); return(result); } catch (Exception) { throw; } }
/// <summary> /// Send the data of the test to the server. /// </summary> /// <param name="testResultImage">The image to send.</param> public static bool SendImage(TestResultImage testResultImage) { if (!Connect()) throw new InvalidOperationException("Could not connect to image comparer server"); try { if (testResultImage.TestName == null && NUnit.Framework.TestContext.CurrentContext != null) { testResultImage.TestName = NUnit.Framework.TestContext.CurrentContext.Test.FullName; } var networkStream = ImageComparisonServer.GetStream(); var binaryWriter = new BinaryWriter(networkStream); var binaryReader = new BinaryReader(networkStream); // Header binaryWriter.Write((int)ImageServerMessageType.SendImage); GameTestBase.TestGameLogger.Info(@"Sending image information..."); testResultImage.Write(binaryWriter); return binaryReader.ReadBoolean(); } catch (Exception) { throw; } }
/// <summary> /// Send the data of the test to the server. /// </summary> /// <param name="testResultImage">The image to send.</param> public static bool SendImage(TestResultImage testResultImage) { if (!Connect()) throw new InvalidOperationException("Could not connect to image comparer server"); try { if (testResultImage.TestName == null && NUnit.Framework.TestContext.CurrentContext != null) { testResultImage.TestName = NUnit.Framework.TestContext.CurrentContext.Test.FullName; } var binaryWriter = new BinaryWriter(ImageComparisonServer.WriteStream); var binaryReader = new BinaryReader(ImageComparisonServer.ReadStream); // Header binaryWriter.Write((int)ImageServerMessageType.SendImage); GameTestBase.TestGameLogger.Info(@"Sending image information..."); var sw = new Stopwatch(); sw.Start(); testResultImage.Write(binaryWriter); sw.Stop(); GameTestBase.TestGameLogger.Info("Total calculation time: {0}", sw.Elapsed); return binaryReader.ReadBoolean(); } catch (Exception) { return false; } }
public TestResultServerImage(ImageComparerClient client) { Client = client; ClientImage = new TestResultImage(); }
/// <summary> /// Send the data of the test to the server. /// </summary> /// <param name="testResultImage">The image to send.</param> public static bool SendImage(TestResultImage testResultImage) { var task = SendImageAsync(testResultImage); task.Wait(); return task.Result; }
/// <summary> /// Send the data of the test to the server. /// </summary> /// <param name="testResultImage">The image to send.</param> public static async Task<bool> SendImageAsync(TestResultImage testResultImage) { if (!Connect()) throw new InvalidOperationException("Could not connect to image comparer server"); try { if (testResultImage.TestName == null && NUnit.Framework.TestContext.CurrentContext != null) { testResultImage.TestName = NUnit.Framework.TestContext.CurrentContext.Test.FullName; } // Send initial parameters using (var memoryStream = new MemoryStream()) { var binaryWriter = new BinaryWriter(memoryStream); // Header binaryWriter.Write((int)ImageServerMessageType.SendImage); GameTestBase.TestGameLogger.Info(@"Sending image information..."); testResultImage.Write(binaryWriter); var dataWriter = new DataWriter(imageComparisonServer.OutputStream); dataWriter.WriteBytes(memoryStream.ToArray()); await dataWriter.StoreAsync(); await dataWriter.FlushAsync(); dataWriter.DetachStream(); } var dataReader = new DataReader(imageComparisonServer.InputStream); await dataReader.LoadAsync(1); var result = dataReader.ReadBoolean(); dataReader.DetachStream(); return result; } catch (Exception) { throw; } }