Ejemplo n.º 1
0
        public void Worker_SessionContextKnownType()
        {
            String         dataToSendSerialized2 = TypeExtension.DefaultString;
            SessionContext context = new SessionContext(this.ToString(), Guid.NewGuid().ToString(), "MyName");
            NameIDModel    dataIn  = new NameIDModel()
            {
                Name = "NameField"
            };
            WorkerParameter <NameIDModel> item2 = new WorkerParameter <NameIDModel>()
            {
                Context = context, DataIn = dataIn
            };
            ISerializer <WorkerParameter <NameIDModel> > serializer2 = new JsonSerializer <WorkerParameter <NameIDModel> >();

            // Test Serialization
            dataToSendSerialized2 = serializer2.Serialize(item2);
            Assert.IsTrue(dataToSendSerialized2 != TypeExtension.DefaultString, "Did not work");
        }
Ejemplo n.º 2
0
        public void Worker_WorkerParameterSerialize()
        {
            // Initialize
            var dataToSendSerialized = TypeExtension.DefaultString;
            var context = new SessionContext(this.ToString(), Guid.NewGuid().ToString(), "MyName");
            var dataIn  = new NameIDModel()
            {
                Name = "NameField"
            };
            var item1 = new WorkerParameter <NameIDModel>()
            {
                Context = context, DataIn = dataIn
            };
            var serializer = new JsonSerializer <WorkerParameter <NameIDModel> >();

            // Disable exceptions, we just want to look at results
            serializer.ThrowException = false;

            // Test Item1 Serialization
            dataToSendSerialized = serializer.Serialize(item1);
            Assert.IsTrue(dataToSendSerialized != TypeExtension.DefaultString, "Did not work");
            item1 = serializer.Deserialize(dataToSendSerialized);
            Assert.IsTrue(item1 != null, "Did not work.");
        }