Пример #1
0
        // DanyaDone
        private void EmitMultipleRelationsInExpression(JsonEntity declaration)
        {
            this.EmitRelation(declaration.Children[1]);

            if (declaration.Children.Count > 1)
            {
                this.EmitMultipleRelationsInExpression(declaration.Children[2]);
                var operation = declaration.Children[2].Children[0].Value; // operation = multiplerelationsinexpression->multiplerelationsinexpression->logicaloperator
                var ip        = this.bootstrap.Body.GetILProcessor();
                // lhs.value
                ip.Emit(OpCodes.Ldarg_0);
                ip.Emit(OpCodes.Ldfld, declaration.Value);
                // rhs.value
                ip.Emit(OpCodes.Ldarg_1);
                ip.Emit(OpCodes.Ldfld, declaration.Value);

                if (operation == "and")
                {
                    ip.Emit(OpCodes.And);
                }
                else if (operation == "or")
                {
                    ip.Emit(OpCodes.Or);
                }
                else if (operation == "xor")
                {
                    ip.Emit(OpCodes.Xor);
                }
            }
        }
Пример #2
0
        public void Write_Values_Success()
        {
            var jsonEntityChannel = new JsonEntity("Channel", "1", Json);

            Assert.IsTrue(string.Equals(jsonEntityChannel.GetProperty <string>("link"), "http://www.starwars.com", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityChannel.GetProperty <string>("description"), "Star Wars blog.", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityChannel.GetProperty <string>("title"), "Star Wars", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(jsonEntityChannel.GetCollection("item").Count == 0);

            jsonEntityChannel.SetProperty("link", "http://www.starwars.org");
            jsonEntityChannel.SetProperty("description", "Star Wars best blog.");
            jsonEntityChannel.SetProperty("title", "Star Wars is the best");

            Assert.IsTrue(string.Equals(jsonEntityChannel.GetProperty <string>("link"), "http://www.starwars.org", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityChannel.GetProperty <string>("description"), "Star Wars best blog.", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityChannel.GetProperty <string>("title"), "Star Wars is the best", StringComparison.OrdinalIgnoreCase));


            var jsonEntityAddress = jsonEntityChannel.GetEntity("address");

            Assert.IsTrue(string.Equals(jsonEntityAddress.GetProperty <string>("line1"), "123 Main St", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityAddress.GetProperty <string>("city"), "Los Angeles", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityAddress.GetProperty <string>("state"), "CA", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityAddress.GetProperty <string>("country"), "USA", StringComparison.OrdinalIgnoreCase));

            jsonEntityAddress.SetProperty("line1", "123 Strip St");
            jsonEntityAddress.SetProperty("city", "Las Vegas");
            jsonEntityAddress.SetProperty("state", "NV");

            Assert.IsTrue(string.Equals(jsonEntityAddress.GetProperty <string>("line1"), "123 Strip St", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityAddress.GetProperty <string>("city"), "Las Vegas", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityAddress.GetProperty <string>("state"), "NV", StringComparison.OrdinalIgnoreCase));
        }
Пример #3
0
        public void Json_Parse_Test()
        {
            // Arrange
            var str = GetTestData();

            // Act
            var json = JsonEntity.Parse(str);

            // Assert
            Assert.That(json, Is.Not.Null);

            // - order
            Assert.That(json["order"], Is.Not.Null);
            Assert.That(json["order"]["complete"].GetValue <bool>(), Is.True);

            // - order.items
            Assert.That(json["order"]["items"], Is.Not.Null);

            // - order.items[0]
            Assert.That(json["order"]["items"][0], Is.Not.Null);
            Assert.That(json["order"]["items"][0]["name"].GetValue <string>(), Is.EqualTo("Egg"));
            Assert.That(json["order"]["items"][0]["qty"].GetValue <int>(), Is.EqualTo(2));
            Assert.That(json["order"]["items"][0]["price"].GetValue <double>(), Is.EqualTo(3.14));

            // - order.items[1]
            Assert.That(json["order"]["items"][1], Is.Not.Null);
            Assert.That(json["order"]["items"][1]["name"].GetValue <string>(), Is.EqualTo("Bottle of water"));
            Assert.That(json["order"]["items"][1]["qty"].GetValue <int>(), Is.EqualTo(1));
            Assert.That(json["order"]["items"][1]["price"].GetValue <double>(), Is.EqualTo(2.5));
        }
Пример #4
0
        public void RegisterTypes(IContainerRegistry containerRegistry)
        {
            var path   = Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json");
            var entity = new JsonEntity();

            if (!File.Exists(path))
            {
                using (var fs = File.CreateText(path)) {
                    entity.BouyomiPort = 50001;
                    entity.BouyomiHost = "127.0.0.1";
                    var text = JsonConvert.SerializeObject(entity, Formatting.Indented);
                    fs.Write(text);
                    fs.Close();
                }
            }
            var bulder = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json");
            var configuration = bulder.Build();

            containerRegistry.RegisterInstance(configuration);
            containerRegistry.RegisterSingleton <IChatService, ChatService>();
            containerRegistry.RegisterSingleton <IBouyomiService, BouyomiService>();
            containerRegistry.RegisterSingleton <IOAuthManagerable, OAuthManager>();
            containerRegistry.Register <IFileService, FileService>();
            containerRegistry.RegisterSingleton <ISettingDomain, SettingDomain>();
            containerRegistry.RegisterDialog <Setting>(RegionName.SettingRegionName);
            containerRegistry.RegisterInstance(new MixerAPI());
        }
Пример #5
0
 public void EntityReturnsJsonDataAfterContentsAssignment()
 {
     var entity = new JsonEntity<string>(1);
     entity.Contents = "1";
     Assert.IsNotNull(entity.Contents);
     Assert.IsNotNull(entity.JsonData);
 }
Пример #6
0
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            JsonEntity _json      = new JsonEntity();
            var        modelState = context.ModelState;

            if (!modelState.IsValid)
            {
                var    errors       = modelState.Where(n => n.Value.Errors.Count > 0).ToList();
                string errorMessage = "";
                if (errors.Count > 0)
                {
                    foreach (var error in errors)
                    {
                        errorMessage += error.Value.Errors[0].ErrorMessage + " ";
                    }

                    errorMessage.Remove(errorMessage.Length - 1);

                    _json.AddErrorAlert(((int)HttpStatusCode.BadRequest).ToString(), errorMessage.Replace(".", ","));
                }
                else
                {
                    _json.AddErrorAlert(HttpStatusCode.BadRequest, BaseApiMessage.ERROR_COMMON_INVALID_PARAMETER);
                }
                context.Result = new JsonResult(_json, new JsonSerializerSettings()
                {
                    ContractResolver = new DefaultJsonContactResolver()
                    {
                        NamingStrategy = new SnakeCaseNamingStrategy()
                    }
                });
                return;
            }
            base.OnActionExecuting(context);
        }
    public void PlantButtonOnClick()
    {
        try
        {
            IBarcodeReader barcodeReader = new BarcodeReader();
            // decode the current frame
            var result = barcodeReader.Decode(backCamera.GetPixels32(), backCamera.width, backCamera.height);

            if (result != null)
            {
                Debug.Log("DECODED TEXT FROM QR: " + result.Text);
            }

            QrResult = result.Text;
            JsonEntity jsonEntity = new JsonEntity();
            jsonEntity.JsonFlag   = "FactoryQR";
            jsonEntity.JsonObject = QrResult;
            string jsonString = JsonUtility.ToJson(jsonEntity);
            PlantQrCommunication qrCommunication = new PlantQrCommunication();
            qrCommunication.SendDataToServer(jsonString);

            //LoadScene which displays OptimisedRootList of Machines
            SceneManager.LoadScene("YellowStateMachines");
        }
        catch (Exception ex)
        {
            Debug.LogWarning(ex.Message);
            //QrResult = "";
        }
    }
    public void MachineButtonOnClick()
    {
        // do the reading — you might want to attempt to read less often than you draw on the screen for performance sake
        try
        {
            IBarcodeReader barcodeReader = new BarcodeReader();
            // decode the current frame
            var result = barcodeReader.Decode(backCamera.GetPixels32(), backCamera.width, backCamera.height);

            if (result != null)
            {
                Debug.Log("DECODED TEXT FROM QR: " + result.Text);
            }

            QrResult = result.Text;
            JsonEntity jsonEntity = new JsonEntity();
            jsonEntity.JsonFlag   = "MachineQR";
            jsonEntity.JsonObject = QrResult;
            string jsonString = JsonUtility.ToJson(jsonEntity);
            MachineQrCommunication qrCommunication = new MachineQrCommunication();
            qrCommunication.SendDataToServer(jsonString);

            //LoadScene which displays OptimisedRootList of Machines
            SceneManager.LoadScene("OperationScene");
        }
        catch (Exception ex)
        {
            Debug.LogWarning(ex.Message);
            //QrResult = "";
        }
    }
Пример #9
0
        public static XmlElement Convert(JsonEntity entity)
        {
            if (entity is JsonString)
            {
                return(Convert((JsonString)entity));
            }

            if (entity is JsonBoolean)
            {
                return(Convert((JsonBoolean)entity));
            }

            if (entity is JsonNull)
            {
                return(Convert((JsonNull)entity));
            }

            if (entity is JsonNumber)
            {
                return(Convert((JsonNumber)entity));
            }

            if (entity is JsonArray)
            {
                return(Convert((JsonArray)entity));
            }

            if (entity is JsonObject)
            {
                return(Convert((JsonObject)entity));
            }

            throw new ArgumentException("Entity type is unknown.", nameof(entity));
        }
Пример #10
0
 public void EntityReturnsNullsAfterInvalidJsonAssignment()
 {
     var entity = new JsonEntity<string>(1);
     entity.JsonData = "$&*&D[]:";
     Assert.IsNull(entity.JsonData);
     Assert.IsNull(entity.Contents);
 }
Пример #11
0
    public static JsonEntity requestJson() //获取某个是否被锁
    {
        jsonString = File.ReadAllText(path);
        JsonEntity json = JsonUtility.FromJson <JsonEntity>(jsonString);

        return(json);
    }
Пример #12
0
        public void EmptyEntityReturnsNullData()
        {
            var entity = new JsonEntity <string>(1);

            Assert.IsNull(entity.Contents);
            Assert.IsNull(entity.JsonData);
        }
Пример #13
0
        private void EmitStatement(JsonEntity statement)
        {
            var ivasiq = statement.Children[0];

            switch (ivasiq.Type)
            {
            case "Assignment":
                this.EmitAssignment(ivasiq);
                break;

            case "RoutineCall":
                this.EmitRoutineCall(ivasiq);
                break;

            case "WhileLoop":
                this.EmitWhileLoop(ivasiq);
                break;

            case "ForLoop":
                this.EmitForLoop(ivasiq);
                break;

            case "IfStatement":
                this.EmitIfStatement(ivasiq);
                break;

            default:
                throw new Exception("Statement Error");
            }
        }
Пример #14
0
        private void EmitExpression(JsonEntity expression)
        {
            this.EmitRelation(expression.Children[0]);
            //if (expression.Children.Count > 1) {
            //    this.EmitMultipleRelationsInExpression(expression.Children[1]);
            //    var operation = expression.Children[1].Children[0].Value; // operation = expression->multiplerelationsinexpression->logicaloperator

            //    var ip = this.bootstrap.Body.GetILProcessor();
            //    // lhs.value
            //    ip.Emit(OpCodes.Ldarg_0);
            //    ip.Emit(OpCodes.Ldfld, expression.Value);
            //    // rhs.value
            //    ip.Emit(OpCodes.Ldarg_1);
            //    ip.Emit(OpCodes.Ldfld, expression.Value);

            //    if (operation == "and") {
            //        ip.Emit(OpCodes.And);
            //    }
            //    else if (operation == "or") {
            //        ip.Emit(OpCodes.Or);
            //    }
            //    else if (operation == "xor") {
            //        ip.Emit(OpCodes.Xor);
            //    }
            //}
        }
Пример #15
0
 public void EntityReturnsNullsAfterInvalidContentsAssignment()
 {
     var entity = new JsonEntity<PathologicalClass>(1);
     entity.Contents = new PathologicalClass();
     Assert.IsNull(entity.JsonData);
     Assert.IsNull(entity.Contents);
 }
Пример #16
0
    public void ApplyButtonOnClick(Toggle toggle)
    {
        string finilisedList;

        if (toggle.isOn.Equals(true))
        {
            YellowStateMachinesList[counter].errorState = "2";
            if (counter == size)
            {
                //Send Updated List to the server
                //Load Optimised List Scene
                // finilisedList = JsonUtility.ToJson(YellowStateMachinesList);
                finilisedList = JsonUtility.ToJson(YellowStateMachinesList);
                JsonEntity jsonEntity = new JsonEntity();
                jsonEntity.JsonFlag   = "OptimisationRequest";
                jsonEntity.JsonObject = finilisedList;
                string optimisationMessage = JsonUtility.ToJson(jsonEntity);
                OptimisedListCommunication optimisedListCommunication = new OptimisedListCommunication();
                optimisedListCommunication.SendDataToServer(optimisationMessage);
                SceneManager.LoadScene("OptimisedRoot");
            }
            else
            {
                GameObject         newMachine = Instantiate(ListItemPrefab) as GameObject;
                ListItemController controller = newMachine.GetComponent <ListItemController>();
                controller.MachineId.text       = YellowStateMachinesList[counter + 1].id;
                controller.OperationToDo.text   = YellowStateMachinesList[counter + 1].operationToDo;
                newMachine.transform.parent     = ContentPanel.transform;
                newMachine.transform.localScale = Vector3.one;
                counter++;
            }
        }
        else
        {
            YellowStateMachinesList[counter].errorState = "0";
            if (counter == size)
            {
                //Send Updated List to the server
                //Load Optimised List Scene
                finilisedList = JsonUtility.ToJson(YellowStateMachinesList);
                JsonEntity jsonEntity = new JsonEntity();
                jsonEntity.JsonFlag   = "OptimisationRequest";
                jsonEntity.JsonObject = finilisedList;
                string optimisationMessage = JsonUtility.ToJson(jsonEntity);
                OptimisedListCommunication optimisedListCommunication = new OptimisedListCommunication();
                optimisedListCommunication.SendDataToServer(optimisationMessage);
                SceneManager.LoadScene("OptimisedRoot");
            }
            else
            {
                GameObject         newMachine = Instantiate(ListItemPrefab) as GameObject;
                ListItemController controller = newMachine.GetComponent <ListItemController>();
                controller.MachineId.text       = YellowStateMachinesList[counter + 1].id;
                controller.OperationToDo.text   = YellowStateMachinesList[counter + 1].operationToDo;
                newMachine.transform.parent     = ContentPanel.transform;
                newMachine.transform.localScale = Vector3.one;
                counter++;
            }
        }
    }
Пример #17
0
        public JsonEntity CreateNewUser(IMitraisEntity mitraisEntity, UserDTO model)
        {
            JsonEntity _json = new JsonEntity();

            try
            {
                MD_User new_user = new MD_User()
                {
                    phone      = model.Phone,
                    dob        = (model.Dob == null) ? String.Empty : model.Dob,
                    first_name = model.First_Name,
                    last_name  = model.Last_Name,
                    gender     = model.Gender,
                    email      = model.Email
                };

                user_repo.Insert(mitraisEntity, "ID", new_user);

                _json.AddSuccessData("Successfully added new user");
            }
            catch (Exception ex)
            {
                _json.AddExceptionAlert(ex);
            }
            return(_json);
        }
Пример #18
0
 public void EntityReturnsNullContentsDataAfterNullJsonAssignment()
 {
     var entity = new JsonEntity<string>(1);
     entity.JsonData = null;
     Assert.IsNull(entity.Contents);
     Assert.IsNull(entity.JsonData);
 }
Пример #19
0
 // DanyaDone
 private void EmitFactor(JsonEntity factor)
 {
     this.EmitSummand(factor.Children[0]);
     if (factor.Children.Count > 1)
     {
         this.EmitSummands(factor.Children[1]);
     }
 }
Пример #20
0
        public void TryParseArrayJson_InvalidJson()
        {
            IReadOnlyCollection <UserResult> result;
            var isSuccess = JsonEntity.TryParseJsonArray("this is not JSON", out result);

            Assert.IsFalse(isSuccess);
            Assert.IsNull(result);
        }
Пример #21
0
        public void TryParseJson_Null()
        {
            UserResult result;
            var        isSuccess = JsonEntity.TryParseJson(null, out result);

            Assert.IsFalse(isSuccess);
            Assert.IsNull(result);
        }
Пример #22
0
        public void EntityReturnsNullsAfterInvalidContentsAssignment()
        {
            var entity = new JsonEntity <PathologicalClass>(1);

            entity.Contents = new PathologicalClass();
            Assert.IsNull(entity.JsonData);
            Assert.IsNull(entity.Contents);
        }
Пример #23
0
        public void EntityReturnsNullContentsDataAfterNullJsonAssignment()
        {
            var entity = new JsonEntity <string>(1);

            entity.JsonData = null;
            Assert.IsNull(entity.Contents);
            Assert.IsNull(entity.JsonData);
        }
Пример #24
0
        public void EntityReturnsJsonDataAfterContentsAssignment()
        {
            var entity = new JsonEntity <string>(1);

            entity.Contents = "1";
            Assert.IsNotNull(entity.Contents);
            Assert.IsNotNull(entity.JsonData);
        }
Пример #25
0
        public void TryParseArrayJson_EmptyString()
        {
            IReadOnlyCollection <UserResult> result;
            var isSuccess = JsonEntity.TryParseJsonArray(string.Empty, out result);

            Assert.IsTrue(isSuccess);
            Assert.IsNull(result);
        }
Пример #26
0
        public void TryParseJson_InvalidJson()
        {
            UserResult result;
            var        isSuccess = JsonEntity.TryParseJson("this is not JSON", out result);

            Assert.IsFalse(isSuccess);
            Assert.IsNull(result);
        }
Пример #27
0
        public void EntityReturnsNullsAfterInvalidJsonAssignment()
        {
            var entity = new JsonEntity <string>(1);

            entity.JsonData = "$&*&D[]:";
            Assert.IsNull(entity.JsonData);
            Assert.IsNull(entity.Contents);
        }
Пример #28
0
        public void TryParseArrayJson_Null()
        {
            IReadOnlyCollection <UserResult> result;
            var isSuccess = JsonEntity.TryParseJsonArray(null, out result);

            Assert.IsFalse(isSuccess);
            Assert.IsNull(result);
        }
Пример #29
0
 // DanyaDone
 private void EmitSimple(JsonEntity simple)
 {
     this.EmitFactor(simple.Children[0]);
     if (simple.Children.Count > 1)
     {
         this.EmitFactors(simple.Children[1]);
     }
 }
Пример #30
0
        public void TryParseJson_EmptyString()
        {
            UserResult result;
            var        isSuccess = JsonEntity.TryParseJson(string.Empty, out result);

            Assert.IsTrue(isSuccess);
            Assert.IsNull(result);
        }
Пример #31
0
        public void Read_Values_MissingProperty()
        {
            var jsonEntityChannel = new JsonEntity("Channel", "1", Json);

            Assert.Throws <Exception>(() => jsonEntityChannel.GetCollection("missing"));
            Assert.Throws <Exception>(() => jsonEntityChannel.GetEntity("missing"));
            Assert.Throws <Exception>(() => jsonEntityChannel.GetProperty <string>("missing"));
        }
Пример #32
0
        public void BlankEntity_AddProperty_Success()
        {
            var jsonEntity = new JsonEntity("Blank", "1", "{}");

            Assert.Throws <Exception>(() => jsonEntity.GetProperty <string>("code"));
            jsonEntity.SetProperty("code", "blank");
            Assert.IsTrue(string.Equals(jsonEntity.GetProperty <string>("code"), "blank", StringComparison.OrdinalIgnoreCase));
        }
Пример #33
0
 public void EntityReturnsNewJsonDataWhenRequestedMultipleTimes()
 {
     var entity = new JsonEntity<string>(1);
     entity.Contents = "1";
     var jsonData = entity.JsonData;
     Assert.IsNotNull(jsonData);
     Assert.AreNotSame(entity.JsonData, jsonData);
 }
Пример #34
0
 public void EntityReturnsTheSameContentsDataWhenRequestedMultipleTimes()
 {
     var entity = new JsonEntity<string>(1);
     entity.JsonData = "1";
     var contents = entity.Contents;
     Assert.IsNotNull(contents);
     Assert.AreSame(entity.Contents, contents);
 }
Пример #35
0
        public HttpCode Execute()
        {
            Clear();

            // Connect
            NetworkChannel channel = null;

            try
            {
                channel = new NetworkChannel(Connection);

                // Request
                JsonEntity jsonEntity = (JsonEntity)Entity;
                JsonClient jsonClient = (JsonClient)Client;
                JsonGroup  jsonGroup  = (JsonGroup)Group;

                JsonJoinRequestMessage jsonRequestMessage = new JsonJoinRequestMessage()
                {
                    Entity = jsonEntity, Client = jsonClient, Group = jsonGroup
                };
                JsonPacket jsonRequest = new JsonPacket(jsonRequestMessage);

                HttpRequest httpRequest = new HttpRequest(Session.Id)
                {
                    Data = Session.Encrypt(jsonRequest)
                };
                channel.Send(httpRequest);

                // Response
                HttpResponse httpResponse;
                channel.Receive(out httpResponse);
                Code = httpResponse.Code;

                if (httpResponse.Ok)
                {
                    JsonPacket jsonResponse = JsonPacket.Parse(Session.Decrypt(httpResponse.Data));
                    JsonJoinResponseMessage jsonResponseMessage = JsonJoinResponseMessage.Parse(jsonResponse.Message);

                    // Data
                    Server.Entities = jsonResponseMessage.Entities;
                    Server.Sessions = jsonResponseMessage.Sessions;
                    Server.Clients  = jsonResponseMessage.Clients;
                    Server.Groups   = jsonResponseMessage.Groups;
#if DEBUG
                    Log.Add(httpRequest, httpResponse, jsonRequest, jsonResponse);
#endif
                }
            }
            finally
            {
                if (channel != null)
                {
                    channel.Shutdown();
                }
            }

            return(Code);
        }
Пример #36
0
        public static void DoesNotCreateNewInstance()
        {
            var expected = new JsonEntity(string.Empty, null, string.Empty, 0);
            var actual   = expected.WithScore(0.1);

            actual.Should().BeSameAs(expected);
            expected.AdditionalProperties.ContainsKey("score").Should().BeTrue();
            expected.AdditionalProperties["score"].As <double>().Should().BeApproximately(0.1, Epsilon);
        }
        public void Serialize_WhenPrivateSetterExists_IsSerialized()
        {
            var entity = new JsonEntity();
            entity.SetName("Daniel");

            var json = _jsonSerializer.Serialize(entity);

            Assert.AreEqual("{\"Name\":\"Daniel\"}", json);
        }
        public void ToJsonOrEmptyString_WhenPrivateSetterExists_IsSerialized()
        {
            var entity = new JsonEntity();
            entity.SetName("Daniel");

            var json = JsonSerialization.ToJsonOrEmptyString(entity);

            Assert.AreEqual("{\"Name\":\"Daniel\"}", json);
        }
        public override void Serialize_WhenPrivateSetterExists_IsSerialized()
        {
            var entity = new JsonEntity();
            entity.SetName("Daniel");
            entity.SetAge(32);

            var json = Serializer.Serialize(entity);

            Assert.AreEqual("{\"Name\":\"Daniel\",\"Age\":32}", json);
        }
Пример #40
0
 public void EntityReturnsDifferentDataAfterJsonAssignment()
 {
     var entity = new JsonEntity<string>(1);
     entity.JsonData = "1";
     var jsonData = entity.JsonData;
     var contents = entity.Contents;
     entity.JsonData = "2";
     Assert.AreNotEqual((object) jsonData, entity.JsonData);
     Assert.AreNotEqual((object) contents, entity.Contents);
 }
Пример #41
0
 public void EmptyEntityReturnsNullData()
 {
     var entity = new JsonEntity<string>(1);
     Assert.IsNull(entity.Contents);
     Assert.IsNull(entity.JsonData);
 }
Пример #42
0
 public void RoundTripValueAssignmentWorksProperlyWhenChangesAreMadeDirectlyToContents()
 {
     var entity1 = new JsonEntity<RegularClass>(1);
     entity1.Contents = new RegularClass();
     entity1.Contents.Value = 42;
     var entity2 = new JsonEntity<RegularClass>(2);
     entity2.JsonData = entity1.JsonData;
     Assert.AreEqual((object) entity1.Contents.Value, entity2.Contents.Value);
 }
Пример #43
0
 public void RoundTripValueAssignmentWorksProperlyForConvertableType()
 {
     var entity1 = new JsonEntity<RegularClass>(1);
     entity1.Contents = new RegularClass { Value = 1 };
     var entity2 = new JsonEntity<AnotherRegularClass>(2);
     entity2.JsonData = entity1.JsonData;
     Assert.AreEqual((object) entity1.Contents.Value.ToString(), entity2.Contents.Value);
 }