public void NewToOld() { var oldMsg = new OldRemoveSubscription("the message", new Uri("http://bob/phil")); var oldold = Factory.ConvertToOldRemoveSubscription(oldMsg); using (var newStream = new MemoryStream()) { PlainFormatter.Serialize(newStream, oldold); newStream.Position = 0; using (var oldStream = new MemoryStream()) { using (var str = File.OpenRead(_pathToFile)) { var buff = new byte[str.Length]; str.Read(buff, 0, buff.Length); oldStream.Write(buff, 0, buff.Length); } var newFileName = ".\\new-{0}.txt".FormatWith(oldMsg.GetType().Name); if (File.Exists(newFileName)) { File.Delete(newFileName); } using (var fs = File.OpenWrite(newFileName)) { fs.Write(newStream.ToArray(), 0, newStream.ToArray().Length); } StreamAssert.AreEqual(oldStream, newStream); } } }
public void OldToNew() { OldRemoveSubscription oldMsg; using (var str = File.OpenRead(_pathToFile)) { var o = PlainFormatter.Deserialize(str); oldMsg = Factory.ConvertToNewRemoveSubscription(o); } Assert.AreEqual(new Uri("http://bob/phil"), oldMsg.Subscription.EndpointUri); }
public void OldToNew() { OldCancelSubscriptionUpdates oldMsg; using (var str = File.OpenRead(_pathToFile)) { var o = PlainFormatter.Deserialize(str); oldMsg = Factory.ConvertToNewCancelSubscriptionUpdates(o); } Assert.AreEqual(new Uri("http://bob/phil"), oldMsg.RequestingUri); }
//-------------------------------------------------------------------------------------- /// <summary> /// ctor /// </summary> //-------------------------------------------------------------------------------------- public VarmintWidgetScrollView() { ClipToBounds = true; this.SetCustomRender((gt, w) => { ScrollBy(_momentum); _momentum *= .9f; Renderer.DrawBox(AbsoluteOffset, Size, RenderBackgroundColor); }); this.OnDrag += VarmintWidgetScrollView_OnDrag; this.OnFlick += VarmintWidgetScrollView_OnFlick; _innerContent = new PlainFormatter(); _innerContent.Renderer = new NullRenderer(); base.AddChild(_innerContent); }
public void NewToOld() //strong to weak { IList <MassTransit.ServiceBus.Subcriptions.Subscription> subs = new List <MassTransit.ServiceBus.Subcriptions.Subscription>(); subs.Add(new MassTransit.ServiceBus.Subcriptions.Messages.Subscription("the_message", new Uri("http://bob/phil"))); var oldMsg = new MassTransit.ServiceBus.Subcriptions.Messages.OldCacheUpdateResponse(subs); var oldold = Factory.ConvertToOldCacheUpdateResponse(oldMsg); using (var newStream = new MemoryStream()) { PlainFormatter.Serialize(newStream, oldold); newStream.Position = 0; using (var oldStream = new MemoryStream()) { using (var str = File.OpenRead(_pathToFile)) { var buff = new byte[str.Length]; str.Read(buff, 0, buff.Length); oldStream.Write(buff, 0, buff.Length); } var newFileName = ".\\new-{0}.txt".FormatWith(oldMsg.GetType().Name); if (File.Exists(newFileName)) { File.Delete(newFileName); } using (var fs = File.OpenWrite(newFileName)) { fs.Write(newStream.ToArray(), 0, newStream.ToArray().Length); } //TODO: Hmmm Weird Assert.AreEqual(oldStream.Length, newStream.Length - 2); //StreamAssert.AreEqual(oldStream, newStream); } } }