public void SerializeActorFactory2()
 {
     var store = new Store(new DefaultSerializer(Pipe.ControlChannelEncoding));
     var customer = new Customer(new Actor());
     customer.Firstname = "george";
     store.Persist(typeof(Customer), customer, "testCustomer33");
     //Assert.AreEqual(customer.Firstname, result.Firstname);
 }
 public void SerializeMethodInfo()
 {
     var customer = new Customer(12);
     var method = typeof(Customer).GetMethod("UpdateName");
     var binarySerializer = new BinarySerializer();
     var buffer = binarySerializer.GetBuffer(method);
     var methodInfo = (MethodInfo)binarySerializer.Deserializer(buffer, typeof(MethodInfo));
     Assert.IsInstanceOfType(methodInfo, typeof(MethodInfo));
     Assert.AreEqual("UpdateName", methodInfo.Name);
     Assert.AreEqual(method, methodInfo);
 }
        public void SerializeActorFactory()
        {
            using (var context = NetMQContext.Create())
            using (var testActor = new Actor(context))
            {

                var serializer = new DefaultSerializer(Pipe.ControlChannelEncoding);
                var customer = new Customer(testActor);
                customer.Firstname = "george";
                var buffer = serializer.GetBuffer(customer);
                var result = serializer.Deserializer<Customer>(buffer);
                Assert.AreEqual(customer.Firstname, result.Firstname);
            }
        }
 public void Call_SerializeandDeserialisedMethodInfo_Method_Successful()
 {
     var customer = new Customer(-1);
     var method = typeof(Customer).GetMethod("UpdateName");
     var binarySerializer = new BinarySerializer();
     var buffer = binarySerializer.GetBuffer(method);
     var methodInfo = (MethodInfo)binarySerializer.Deserializer(buffer, typeof(MethodInfo));
     Assert.IsInstanceOfType(methodInfo, typeof(MethodInfo));
     Assert.AreEqual("UpdateName", methodInfo.Name);
     object[] parameters = new object[1];
     parameters[0] = "XXXX";
     var result = methodInfo.Invoke(customer, parameters);
     Assert.AreEqual("XXXX", customer.Lastname);
 }
示例#5
0
        public void SerializerTest2()
        {
            var serializer = new Daytona.Store.Serializer(Encoding.Unicode);
            var cust = new Customer
            {
                Firstname = "Jie",
                Lastname = "wilson"
            };
            var pl = new DBPayload<Customer>();
            pl.Payload = cust;
            var input = serializer.GetSerializedPayload<Customer>(pl);

            var output = serializer.Deserializer<DBPayload<Customer>>(input);
            Assert.AreEqual(pl.Payload.Firstname, output.Payload.Firstname);
            Assert.AreEqual(pl.Payload.Lastname, output.Payload.Lastname);
        }
示例#6
0
 public void SaveACustomer()
 {
     using (Daytona.Store.Context context = new Daytona.Store.Context())
     {
         using (var connection = context.GetConnection<Customer>())
         {
             var customer = new Customer
             {
                 Firstname = "John",
                 Lastname = "Lemon"
             };
             var task = connection.Save(customer);
             int id = task.Result;
             Assert.AreEqual(1, id);
         }
     }
 }
示例#7
0
        public void ReadfromPersistenceTest()
        {
            var dontCreateChannels = true;
            using (var actor = new Actor<Customer>())
            {
                var customer = new Customer(1);
                customer.Firstname = "John";
                customer.Lastname = "off yer Rocker mate";
                actor.PersistanceSerializer = new DefaultSerializer(Pipe.ControlChannelEncoding);
                var returnedCustomer = actor.ReadfromPersistence(@"TestHelpers.Customer");
                Assert.AreEqual(customer.Firstname, returnedCustomer.Firstname);

                Assert.AreEqual(customer.Lastname, returnedCustomer.Lastname);
            }
        }
示例#8
0
        public void PersistSelfTest()
        {
            using (var context = NetMQContext.Create())
            {
                using (var exchange = new Exchange(context))
                {
                    exchange.Start();

                    using (var actor = new Actor<Customer>(context))
                    {
                        var customer = new Customer(1);
                        customer.Firstname = "John";
                        customer.Lastname = "off yer Rocker mate";

                        actor.PersistSelf(typeof(Customer), customer, new DefaultSerializer(Pipe.ControlChannelEncoding));
                    }
                    
                    exchange.Stop(true);
                }
            }
        }
示例#9
0
        private static string SynchronizedSender(string input)
        {
            using (var context = ZmqContext.Create())
            {
                using (ZmqSocket pub = Helper.GetConnectedPublishSocket(context, Pipe.PublishAddressClient),
                      syncService = context.CreateSocket(SocketType.REP))
                {
                    //syncService.Connect(Pipe.PubSubControlFrontAddressClient);
                    //for (int i = 0; i < 1; i++)
                    //{
                    //    syncService.Receive(Encoding.Unicode);
                    //    syncService.Send("", Encoding.Unicode);
                    //}

                    for (int i = 0; i < 100000; i++)
                    {
                        Console.WriteLine("Enter to send message=>");
                        input = Console.ReadLine();

                        if (input == "Exit") break;

                        var cust = new Customer
                        {
                            Firstname = "John",
                            Lastname = "Lemon"
                        };
                        var pl = new Daytona.Store.DBPayload<Customer>();
                        pl.Payload = cust;
                        ISerializer serializer = new Daytona.Store.Serializer(Encoding.Unicode);
                        Helper.SendOneMessageOfType<Daytona.Store.DBPayload<Customer>>("Writer", pl, serializer, pub);
                        // Helper.SendOneSimpleMessage("Writer", "Hello its me", pub);
                        Console.WriteLine("message sent");
                    }

                    Console.WriteLine("message sent enter to exit=>");
                    input = Console.ReadLine();
                }
            }
            return input;
        }
示例#10
0
 private static void SendCustomers(ZmqContext context)
 {
     ISerializer serializer = new Daytona.Store.Serializer(Encoding.Unicode);
     using (ZmqSocket publisher = context.CreateSocket(SocketType.PUB))
     {
         publisher.Connect("tcp://*****:*****@"c:\dev\sender.log");
         }
         Helper.SendOneSimpleMessage("XXXX", "stop", publisher);
     }
 }