public void IntegrationTest_HappyPath() { byte[] B1 = new byte[] { 0x01, 0x76, 0x1F, 0x87, 0xA1, 0x43, 0x44, 0x46, 0x45 }; byte[] B2 = new byte[] { 0x01, 0x76, 0x1F, 0x87, 0xA1, 0x43, 0x44, 0x46, 0x44 }; var ep1 = new DiffLib.Endpoints.WorkerEndpoint(Conf, new DiffLib.WebApiSender(WorkerBaseAddr)); var task1 = ep1.CreateIdAsync(B1); var result1 = task1.GetAwaiter().GetResult(); Assert.AreNotEqual(result1, null); Assert.IsFalse(string.IsNullOrEmpty(result1.Id)); var ep2 = new DiffLib.Endpoints.WorkerEndpoint(Conf, new DiffLib.WebApiSender(WorkerBaseAddr)); var task2 = ep2.CompleteIdAsync(result1.Id, B2); var result2 = task2.GetAwaiter().GetResult(); Assert.AreNotEqual(result2, null); Assert.IsFalse(string.IsNullOrEmpty(result2.Id)); var ep3 = new DiffLib.Endpoints.CentralEndpoint(WorkerId, Conf, new DiffLib.WebApiSender(CentralBaseAddtr)); var task3 = ep3.GetDiffAsync(result1.Id); var result3 = task3.GetAwaiter().GetResult(); Assert.AreNotEqual(result3, null); Assert.AreNotEqual(result3.Result, null); Assert.IsFalse(string.IsNullOrEmpty(result3.Id)); Assert.IsFalse(string.IsNullOrEmpty(result3.Result.Data1)); Assert.IsFalse(string.IsNullOrEmpty(result3.Result.Data2)); Assert.IsFalse(result3.Result.Offsets.Count == 0); Assert.IsTrue(result3.Result.Result == DiffLib.DiffResultEnum.SameSize_ContentNotEqual); }
/// <summary> /// Request diff operation to central server /// </summary> /// <param name="id"></param> /// <returns></returns> static string Step3(string id) { //Route api holder var newconf = new Utils.RouteConf(); //Endpoint (uses web api sender) that send and recieves objects from server var worker1x = new DiffLib.Endpoints.CentralEndpoint(WorkerId, newconf, new DiffLib.WebApiSender(CentralBaseAddtr)); var task = worker1x.GetDiffAsync(id); try { var realobj = task.GetAwaiter().GetResult(); if (realobj == null) { Console.WriteLine("Step3:Obj is null"); } else { Console.WriteLine($"Result 3: {realobj.Id} | Result(enum):{realobj.Result.Result}"); //Decode string var b1a = Convert.FromBase64String(realobj.Result.Data1); var b2a = Convert.FromBase64String(realobj.Result.Data2); //Outputs the byte arrays Console.Write($"CentralB1 Length: {b1a.Length} Data: "); foreach (var b in b1a) { Console.Write(((int)b).ToString() + ","); } Console.WriteLine(""); Console.Write($"CentralB2 Length: {b2a.Length} Data: "); foreach (var b in b2a) { Console.Write(((int)b).ToString() + ","); } Console.WriteLine(""); //Outputs the offsets if (realobj.Result.Offsets.Count > 0) { foreach (var o in realobj.Result.Offsets) { Console.WriteLine($"Offset: {o.Offset} Length: {o.Length}"); } } return(realobj.Id); } } catch (Exception e) { Console.WriteLine($"Exception: {e}"); } return(null); }