public void NoRootValueCreated()
 {
     string data = "{\"testproperty\" : \"bob\" }";
     var serializer = new JsonDotNetSerializer();
     var value = serializer.Deserialize<TestClass>(data);
     Assert.IsNotNull(value);
     Assert.AreEqual("bob", value.TestProperty);
 }
예제 #2
0
        public void Can_Deserialize_Food()
        {
            string content = SampleDataHelper.GetContent("GetFoodLogs.json");
            var deserializer = new JsonDotNetSerializer();

            Food food = deserializer.Deserialize<Food>(content);

            ValidateFoodData(food);
        }
예제 #3
0
        public void Can_Deserialize_BodyMeasurements()
        {
            string content = SampleDataHelper.GetContent("GetBodyMeasurements.json");
            var deserializer = new JsonDotNetSerializer();

            BodyMeasurements bodyMeasurements = deserializer.Deserialize<BodyMeasurements>(content);

            ValidateBodyMeasurements(bodyMeasurements);
        }
        public void Serialize_should_have_expected_result(int? nullableInt32, string expectedResult)
        {
            var subject = new JsonDotNetSerializer<C>();
            var value = new C { V = nullableInt32 == null ? null : (BsonInt32)nullableInt32.Value };

            var result = Serialize(subject, value);

            result.Should().Equal(ToBson(expectedResult));
        }
예제 #5
0
        public void Can_Deserialize_Food()
        {
            string content = SampleDataHelper.GetContent("GetBloodPressure.json");
            var deserializer = new JsonDotNetSerializer();

            BloodPressureData bp = deserializer.Deserialize<BloodPressureData>(content);

            ValidateBloodPressureData(bp);
        }
예제 #6
0
        public void Can_Deserialize_Profile()
        {
            string content = SampleDataHelper.GetContent("UserProfile.json");
            var deserializer = new JsonDotNetSerializer {RootProperty = "user"};

            var result = deserializer.Deserialize<UserProfile>(content);

            ValidateSingleUserProfile(result);
        }
        public void Deserialize_should_return_expected_result(string json, int? nullableInt32)
        {
            var subject = new JsonDotNetSerializer<C>();
            var expectedResult = nullableInt32 == null ? null : (BsonInt32)nullableInt32.Value;

            var result = Deserialize<C>(subject, ToBson(json));

            result.V.Should().Be(expectedResult);
        }
예제 #8
0
        public void Can_Deserialize_Sleep()
        {
            string content = SampleDataHelper.GetContent("GetSleep.json");
            var deserializer = new JsonDotNetSerializer();

            SleepData sleep = deserializer.Deserialize<SleepData>(content);

            ValidatSleep(sleep);
        }
        public void TryGetItemSerializationInfo_should_throw_when_contract_is_not_an_array_contract()
        {
            var subject = new JsonDotNetSerializer<C>();

            BsonSerializationInfo info;
            Action action = () => subject.TryGetItemSerializationInfo(out info);

            action.ShouldThrow<BsonSerializationException>().And.Message.Contains("is not a JsonArrayContract");
        }
예제 #10
0
        public void Can_Deserialize_Water_Data_Json()
        {
            string content = SampleDataHelper.GetContent("GetWater-WaterData.json");

            var deserializer = new JsonDotNetSerializer();

            WaterData result = deserializer.Deserialize <WaterData>(content);

            ValidateWaterData(result);
        }
예제 #11
0
        public void Can_Deserialize_Friends_None()
        {
            string content      = SampleDataHelper.GetContent("GetFriends-None.json");
            var    deserializer = new JsonDotNetSerializer();

            List <UserProfile> friends = deserializer.GetFriends(content);

            Assert.IsNotNull(friends);
            Assert.IsTrue(friends.Count == 0);
        }
예제 #12
0
        public void Can_Deserialize_Friends_Single()
        {
            string content      = SampleDataHelper.GetContent("GetFriends-Single.json");
            var    deserializer = new JsonDotNetSerializer();

            List <UserProfile> friends = deserializer.GetFriends(content);

            Assert.IsNotNull(friends);
            ValidateSingleFriend(friends);
        }
예제 #13
0
    public static JsonDotNetSerializer RegisterNew(IAppHost appHost, JsonSerializerSettings settings = null)
    {
        var obj = new JsonDotNetSerializer(settings);

        appHost.ContentTypes.Register(
            "application/json",
            obj.WriteObjectToStream,
            obj.ReadObjectFromStream);
        return(obj);
    }
예제 #14
0
        public void Can_Deserialize_Profile()
        {
            string content      = SampleDataHelper.GetContent("UserProfile.json");
            var    deserializer = new JsonDotNetSerializer {
                RootProperty = "user"
            };

            var result = deserializer.Deserialize <UserProfile>(content);

            ValidateSingleUserProfile(result);
        }
예제 #15
0
        public void RootPropertyValueCreated()
        {
            string data = "{\"testclass\" : {\"testproperty\" : \"bob\" } }";
            JsonDotNetSerializer serializer = new JsonDotNetSerializer();

            serializer.RootProperty = "testclass";
            TestClass value = serializer.Deserialize <TestClass>(data);

            Assert.IsNotNull(value);
            Assert.AreEqual("bob", value.TestProperty);
        }
예제 #16
0
        public void Can_Deserialize_Activities_Distance()
        {
            string content = SampleDataHelper.GetContent("TimeSeries-ActivitiesDistance.json");
            var deserializer = new JsonDotNetSerializer
            {
                RootProperty = TimeSeriesResourceType.Distance.ToTimeSeriesProperty()
            };

            var result = deserializer.GetTimeSeriesDataList(content);
            ValidateDataList(result);
        }
예제 #17
0
        public void Can_Deserialize_ActivityGoal_FromActivities()
        {
            string content      = SampleDataHelper.GetContent("GetActivities.json");
            var    deserializer = new JsonDotNetSerializer {
                RootProperty = "goals"
            };

            ActivityGoals goal = deserializer.Deserialize <ActivityGoals>(content);

            ValidateActivityGoals(goal);
        }
예제 #18
0
        public void Can_Deserialize_ActivitySummary()
        {
            string content      = SampleDataHelper.GetContent("GetActivities.json");
            var    deserializer = new JsonDotNetSerializer {
                RootProperty = "summary"
            };

            ActivitySummary summary = deserializer.Deserialize <ActivitySummary>(content);

            ValidateActivitySummary(summary);
        }
        public void Can_Deserialize_Friends_Multiple()
        {
            string content = SampleDataHelper.GetContent("GetFriends-Multiple.json");
            JsonDotNetSerializer deserializer = new JsonDotNetSerializer();

            List <UserProfile> friends = deserializer.GetFriends(content);

            Assert.IsNotNull(friends);
            Assert.IsTrue(friends.Count == 3);

            ValidateMultipleFriends(friends);
        }
예제 #20
0
        public Jet()
        {
            RestClient = new RestClient(ApiUrl);

            Serializer = new JsonDotNetSerializer(new JsonSerializer
            {
                ContractResolver      = new PrivatePropertyContractResolver(),
                MissingMemberHandling = MissingMemberHandling.Ignore,
                DefaultValueHandling  = DefaultValueHandling.Ignore,
                NullValueHandling     = NullValueHandling.Include
            });
        }
예제 #21
0
        public void Can_Deserialize_HeartRateTimeSeries()
        {
            //assemble
            string content   = SampleDataHelper.GetContent("GetHeartRateTimeSeries.json");
            var    seralizer = new JsonDotNetSerializer();

            //act
            var stats = seralizer.GetHeartActivitiesTimeSeries(content);

            //assert
            ValidateHeartRateTimeSeriesData(stats);
        }
예제 #22
0
        public void Can_Deserialize_Activities_Distance()
        {
            string content = SampleDataHelper.GetContent("TimeSeries-ActivitiesDistance.json");
            JsonDotNetSerializer deserializer = new JsonDotNetSerializer
            {
                RootProperty = TimeSeriesResourceType.Distance.ToTimeSeriesProperty()
            };

            TimeSeriesDataList result = deserializer.GetTimeSeriesDataList(content);

            ValidateDataList(result);
        }
        public void Can_Deserialize_ApiError()
        {
            string content = SampleDataHelper.GetContent("ApiError.json");

            List <ApiError> result = new JsonDotNetSerializer().ParseErrors(content);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 1);
            ApiError error = result.First();

            Assert.AreEqual("request", error.ErrorType);
            Assert.AreEqual("n/a", error.FieldName);
        }
예제 #24
0
        public void Can_Deserialize_HeartRateIntradayTimeSeries()
        {
            //assemble
            string   content   = SampleDataHelper.GetContent("GetHeartRateIntradayTimeSeries1.1.json");
            DateTime date      = DateTime.Parse("2017-08-21"); //hardcoded because extension expects a date. In any other use case, a date would be available
            var      seralizer = new JsonDotNetSerializer();

            //act
            var stats = seralizer.GetHeartRateIntraday(date, content);

            //assert
            ValidateHeartRateIntradayTimeSeriesData(stats);
        }
예제 #25
0
        public void Serialize_DynamicObjectWithVariousDataTypes_ReturnsValidJSON()
        {
            dynamic data = new ExpandoObject();

            data.Id        = 1;
            data.Title     = "Hello, world";
            data.Value     = 7.17;
            data.CreatedOn = new DateTime(2013, 6, 6, 17, 15, 1, 2);

            var result = new JsonDotNetSerializer().Serialize(data);

            Assert.AreEqual("{\r\n  \"Id\": 1,\r\n  \"Title\": \"Hello, world\",\r\n  \"Value\": 7.17,\r\n  \"CreatedOn\": \"2013-06-06T17:15:01.002\"\r\n}", result);
        }
예제 #26
0
        public void Can_Deserialize_UpdatedResource()
        {
            // aka Add Subscription response
            var content      = SampleDataHelper.GetContent("AddSubscriptionResponse.json");
            var deserializer = new JsonDotNetSerializer();

            var subscription = deserializer.Deserialize <ApiSubscription>(content);

            Assert.AreEqual(APICollectionType.user, subscription.CollectionType);
            Assert.AreEqual("227YZL", subscription.OwnerId);
            Assert.AreEqual("1", subscription.SubscriberId);
            Assert.AreEqual("323", subscription.SubscriptionId);
        }
        public void Can_Deserialise_Single_Device_Details()
        {
            string content = SampleDataHelper.GetContent("GetDevices-Single.json");
            JsonDotNetSerializer deserializer = new JsonDotNetSerializer();

            List <Device> result = deserializer.Deserialize <List <Device> >(content);

            Assert.IsTrue(result.Count == 1);

            Device device = result.First();

            ValidateSingleDevice(device);
        }
        public void TryGetItemSerializationInfo_should_return_expected_result()
        {
            var subject = new JsonDotNetSerializer<int[]>();

            BsonSerializationInfo info;
            var result = subject.TryGetItemSerializationInfo(out info);

            result.Should().BeTrue();
            info.ElementName.Should().BeNull();
            info.NominalType.Should().Be(typeof(int));
            info.Serializer.Should().BeOfType<JsonDotNetSerializer<int>>();
            info.Serializer.ValueType.Should().Be(typeof(int));
        }
        public void Can_Deserialize_ApiError_Forbidden()
        {
            string content = SampleDataHelper.GetContent("ApiError-Request-Forbidden.json");

            List <ApiError> result = new JsonDotNetSerializer().ParseErrors(content);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 1);
            ApiError error = result.First();

            Assert.AreEqual("insufficient_permissions", error.ErrorType);
            Assert.AreEqual(null, error.FieldName);
            Assert.AreEqual("Read-only API client is not authorized to update resources.", error.Message);
        }
        public void Can_Deserialize_ApiError_BadRequest()
        {
            string content = SampleDataHelper.GetContent("ApiError-Request-BadRequest.json");

            List <ApiError> result = new JsonDotNetSerializer().ParseErrors(content);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 1);
            ApiError error = result.First();

            Assert.AreEqual("invalid_request", error.ErrorType);
            Assert.AreEqual("n/a", error.FieldName);
            Assert.AreEqual("There was an error reading the request body.", error.Message);
        }
        public void Can_Deserialize_ApiError_Unauthorized()
        {
            string content = SampleDataHelper.GetContent("ApiError-Request-Unauthorized.json");

            List <ApiError> result = new JsonDotNetSerializer().ParseErrors(content);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 1);
            ApiError error = result.First();

            Assert.AreEqual("invalid_request", error.ErrorType);
            Assert.AreEqual(null, error.FieldName);
            Assert.AreEqual("Authorization header required.", error.Message);
        }
예제 #32
0
        public void Can_Deserialize_ApiError()
        {
            string content = SampleDataHelper.GetContent("ApiError.json");

            var deserializer = new JsonDotNetSerializer();
            deserializer.RootProperty = "errors";
            List<ApiError> result = deserializer.Deserialize<List<ApiError>>(content);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 1);
            ApiError error = result.First();
            Assert.AreEqual(ErrorType.Request, error.ErrorType);
            Assert.AreEqual("n/a", error.FieldName);
        }
예제 #33
0
        public void Can_Deserialize_Water_Log_Json()
        {
            string content = SampleDataHelper.GetContent("LogWater-WaterLog.json");

            var deserializer = new JsonDotNetSerializer {
                RootProperty = "waterLog"
            };

            WaterLog result = deserializer.Deserialize <WaterLog>(content);

            Assert.IsNotNull(result);
            Assert.AreEqual(508728882, result.LogId);
            Assert.AreEqual(300, result.Amount);
        }
예제 #34
0
        public GSPServiceBase()
        {
            JsonSerializerSettings _jsonSettings = new JsonSerializerSettings();

            _jsonSettings.Converters.Add(new JsonNETDateTimeConverter());
            _jsonSettings.Converters.Add(new JsonNetIServiceResultConverter());
            _jsonSettings.Converters.Add(new JsonBulkCreationConverter <Rule>());
            _jsonSettings.Converters.Add(new JsonBulkCreationConverter <RuleResult>());
            _jsonSettings.Converters.Add(new JsonBulkCreationConverter <JobDefinitionSchedule>());
            _jsonSettings.Converters.Add(new JsonBulkCreationConverter <BookingOperationResponse>());

            _jsonSettings.NullValueHandling = NullValueHandling.Ignore;

            _json = new JsonDotNetSerializer(_jsonSettings);
        }
예제 #35
0
        public void Can_Deserialize_ApiError()
        {
            string content = SampleDataHelper.GetContent("ApiError.json");

            var deserializer = new JsonDotNetSerializer();

            deserializer.RootProperty = "errors";
            List <ApiError> result = deserializer.Deserialize <List <ApiError> >(content);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 1);
            ApiError error = result.First();

            Assert.AreEqual(ErrorType.Request, error.ErrorType);
            Assert.AreEqual("n/a", error.FieldName);
        }
예제 #36
0
        public static OAuth2AccessToken ParseAccessTokenResponse(string responseString)
        {
            // assumption is the errors json will return in usual format eg. errors array
            JObject responseObject = JObject.Parse(responseString);

            var error = responseObject["errors"];

            if (error != null)
            {
                //var errors = new JsonDotNetSerializer().ParseErrors(responseString);
                //throw new FitbitException($"Unable to parse token response in method -- {nameof(ParseAccessTokenResponse)}.", errors);
            }

            var deserializer = new JsonDotNetSerializer();

            return(deserializer.Deserialize <OAuth2AccessToken>(responseString));
        }
예제 #37
0
        public void Can_Deserialize_ApiSubscription()
        {
            var content      = SampleDataHelper.GetContent("ListApiSubscriptions.json");
            var deserializer = new JsonDotNetSerializer {
                RootProperty = "apiSubscriptions"
            };

            var subscriptions = deserializer.Deserialize <List <ApiSubscription> >(content);

            Assert.IsNotNull(subscriptions);
            Assert.AreEqual(1, subscriptions.Count);
            var subscription = subscriptions.FirstOrDefault();

            Assert.AreEqual(APICollectionType.user, subscription.CollectionType);
            Assert.AreEqual("227YZL", subscription.OwnerId);
            Assert.AreEqual("1", subscription.SubscriberId);
            Assert.AreEqual("323", subscription.SubscriptionId);
        }
        public void TryGetItemSerializationInfo_should_throw_when_contract_has_a_converter()
        {
            var wrappedSerializer = new Newtonsoft.Json.JsonSerializer();
            var intContract = new Newtonsoft.Json.Serialization.JsonPrimitiveContract(typeof(int))
            {
                Converter = Substitute.For<Newtonsoft.Json.JsonConverter>()
            };
            wrappedSerializer.ContractResolver = new DictionaryContractResolver(
                new Dictionary<Type, JsonContract>
                {
                    { typeof(int), intContract }
                });
            var subject = new JsonDotNetSerializer<int[]>(wrappedSerializer);

            BsonSerializationInfo info;
            Action action = () => subject.TryGetItemSerializationInfo(out info);

            action.ShouldThrow<BsonSerializationException>().And.Message.Contains("has a Converter");
        }
        public void Can_Deserialise_Multiple_Device_Details()
        {
            string content = SampleDataHelper.GetContent("GetDevices-Double.json");
            JsonDotNetSerializer deserializer = new JsonDotNetSerializer();

            List <Device> result = deserializer.Deserialize <List <Device> >(content);

            Assert.IsTrue(result.Count == 2);
            Device device = result.First();

            ValidateSingleDevice(device);

            device = result.Last();
            Assert.AreEqual("High", device.Battery);
            Assert.AreEqual("Aria", device.DeviceVersion);
            Assert.AreEqual("5656777", device.Id);
            Assert.AreEqual(DateTime.Parse("2014-07-17T13:38:13.000"), device.LastSyncTime);
            Assert.AreEqual("SC1111111111", device.Mac);
            Assert.AreEqual(DeviceType.Scale, device.Type);
        }
        public void SimpleSerializationTest()
        {
            var person = new Person
            {
                Name    = "John Doe",
                Age     = 25,
                Hobbies = { "Reading", "Travelling" }
            };
            var    serializer = new JsonDotNetSerializer(new TestTranslatorMapping());
            string json;

            using (var stream = new MemoryStream())
            {
                serializer.Serialize <Person>(stream, person);
                json = Encoding.UTF8.GetString(stream.ToArray());
            }
            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(json)))
            {
                var copy = serializer.Deserialize <Person>(stream);
                Assert.True(person.IsSameAs(copy));
            }
        }
예제 #41
0
        public void ActivityLogsList_JsonParse_Errors()
        {
            string content  = SampleDataHelper.GetContent("GetActivityLogsList2.json");
            var    settings = new JsonSerializerSettings()
            {
                DateParseHandling = DateParseHandling.DateTimeOffset
            };
            var serializer = new JsonDotNetSerializer(settings)
            {
                RootProperty = "activities"
            };

            try
            {
                serializer.Deserialize <ActivityLogsList>(content);
            }
            catch (FitbitParseException e) {
                // Success
            }
            catch (Exception e)
            {
                Assert.Fail();
            }
        }
        public void Can_Deserialize_ApiSubscription_Multi()
        {
            string content = SampleDataHelper.GetContent("ListApiSubscriptionsResponseMultiple.json");
            JsonDotNetSerializer deserializer = new JsonDotNetSerializer {
                RootProperty = "apiSubscriptions"
            };

            List <ApiSubscription> subscriptions = deserializer.Deserialize <List <ApiSubscription> >(content);

            Assert.IsNotNull(subscriptions);
            Assert.AreEqual(2, subscriptions.Count);
            ApiSubscription subscription = subscriptions.FirstOrDefault();

            Assert.AreEqual(APICollectionType.user, subscription.CollectionType);
            Assert.AreEqual("227YZL", subscription.OwnerId);
            Assert.AreEqual("1", subscription.SubscriberId);
            Assert.AreEqual("323", subscription.SubscriptionId);

            subscription = subscriptions.LastOrDefault();
            Assert.AreEqual(APICollectionType.user, subscription.CollectionType);
            Assert.AreEqual("227YZL", subscription.OwnerId);
            Assert.AreEqual("2", subscription.SubscriberId);
            Assert.AreEqual("3230", subscription.SubscriptionId);
        }
 public void DefaultValueCreated_String()
 {
     var serializer = new JsonDotNetSerializer();
     var defaultValue = serializer.Deserialize<TestClass>(string.Empty);
     Assert.AreEqual(default(TestClass), defaultValue);
 }
예제 #44
0
        public void Can_Deserialize_Weight()
        {
            string content = SampleDataHelper.GetContent("GetWeight.json");
            var deserializer = new JsonDotNetSerializer();

            var weight = deserializer.GetWeight(content);

            ValidateWeight(weight);
        }
예제 #45
0
 public void Throws_Exception_With_WhiteSpace()
 {
     var deserializer = new JsonDotNetSerializer();
     deserializer.GetWeight("         ");
 }
예제 #46
0
 public void Throws_Exception_With_Null_String()
 {
     var deserializer = new JsonDotNetSerializer();
     deserializer.GetWeight(null);
 }
예제 #47
0
 public void Throws_Exception_With_Empty_String()
 {
     var deserializer = new JsonDotNetSerializer();
     deserializer.GetWeight(string.Empty);
 }
 public void Initialize()
 {
     serializer = new JsonDotNetSerializer();
 }
예제 #49
0
        public void Can_Deserialize_ActivitySummary()
        {
            string content = SampleDataHelper.GetContent("GetActivities.json");
            var deserializer = new JsonDotNetSerializer { RootProperty = "summary"};

            ActivitySummary summary = deserializer.Deserialize<ActivitySummary>(content);

            ValidateActivitySummary(summary);
        }
예제 #50
0
        public void Can_Deserialize_Water_Log_Json()
        {
            string content = SampleDataHelper.GetContent("LogWater-WaterLog.json");

            var deserializer = new JsonDotNetSerializer { RootProperty = "waterLog"};

            WaterLog result = deserializer.Deserialize<WaterLog>(content);

            Assert.IsNotNull(result);
            Assert.AreEqual(508728882, result.LogId);
            Assert.AreEqual(300, result.Amount);
        }
 private IBsonSerializer<Newtonsoft.Json.Linq.JToken> CreateSubject()
 {
     //var subject = new JValueSerializer();
     var subject = new JsonDotNetSerializer<Newtonsoft.Json.Linq.JToken>();
     return subject;
 }
예제 #52
0
 public ItemMapper(JsonDotNetSerializer serializer)
 {
     _serializer = serializer;
 }
예제 #53
0
            private static void Main(string[] args)
            {
                const string clusterURL = "http://localhost:5555";
                const string hadoopUsername = "******";
                const string hadoopUserPassword = "******";
                var serializer = new JsonDotNetSerializer();
                // Create a new instance of an HBase client.
                var hbaseClient = new HBaseClient(new ClusterCredentials(new Uri(clusterURL), hadoopUsername, hadoopUserPassword));
                var itemMapper = new ItemMapper(serializer);
                hbaseClient.DeleteTable("Items");
                var tableSchema = itemMapper.CreateTableSchema("Items");
                hbaseClient.CreateTable(tableSchema);

                //var perfCheck = new PerformanceChecksManager(hbaseClient, "Items", itemMapper, new ItemsGenerator(),50,100);
                //perfCheck.RunPerformanceLoad();
                
                //Generating item.
                var itemsGenerator = new ItemsGenerator();
                var item = itemsGenerator.CreateItem("mycode");

                //Generating cells relevant to the generate item and saving the entity to Hbae.
                var itemCellSet = itemMapper.GetCells(item, "en-US");
                var stausCell = itemCellSet.rows.Single().values.Single(cell => Encoding.UTF8.GetString(cell.column).Equals("CF1:Status"));
                stausCell.data = new byte[0];
                hbaseClient.StoreCells("Items", itemCellSet);

                //making sure item stored well.
                var originalItemCells = hbaseClient.GetCells("Items", item.Code);
                var originalItemFetchedFromDb = itemMapper.GetDto(originalItemCells, "en-US");

                if (!string.IsNullOrEmpty(originalItemFetchedFromDb.Status))
                    throw new Exception();

                //Describing the conditional update expression.
                var cellToCheck = new Cell { column = Encoding.UTF8.GetBytes("CF1:Status"), data = new byte[0] };

                //manipulating original item.
                stausCell = itemCellSet.rows.Single().values.Single(cell => Encoding.UTF8.GetString(cell.column).Equals("CF1:Status"));
                var newStatusValue = Encoding.UTF8.GetBytes("new");
                stausCell.data = newStatusValue;
                
                //Testing new functionality...

                hbaseClient.CheckAndPutCells("Items", itemCellSet, cellToCheck);
                //Thread.Sleep(1);
                itemCellSet = hbaseClient.GetCells("Items", item.Code);
                var itemFromDb = itemMapper.GetDto(itemCellSet, "en-US");

                if (!itemFromDb.Status.Equals(Encoding.UTF8.GetString(newStatusValue)))
                    throw new Exception();


                #region Old-Helper
                //string clusterURL = "http://localhost:5555";
                //string hadoopUsername = "******";
                //string hadoopUserPassword = "******";
                //string hbaseTableName = "MyCoolTable";

                //// Create a new instance of an HBase client.
                //ClusterCredentials creds = new ClusterCredentials(new Uri(clusterURL), hadoopUsername, hadoopUserPassword);
                //HBaseClient hbaseClient = new HBaseClient(creds);

                //var hbaseHelper = new Helper(hbaseClient, "ThisIsJustATableForShirly1", "DummyKey1ForShirly1");
                //hbaseHelper.CreateTable();
                //var myClass = new Dto()
                //{
                //    Field1 = "1",
                //    Field2 = "2",
                //    Field3 = "3",
                //    Field4 = "4",
                //    Field5 = "5",
                //    NestedData = new NestedDto() { Field1 = "n1", Field2 = "n2" }
                //};

                //hbaseHelper.SaveMyDto(myClass);

                //var dto = hbaseHelper.GetMyDto();
#endregion
            }
예제 #54
0
        public void Can_Deserialize_Water_Data_Json()
        {
            string content = SampleDataHelper.GetContent("GetWater-WaterData.json");

            var deserializer = new JsonDotNetSerializer();

            WaterData result = deserializer.Deserialize<WaterData>(content);

            ValidateWaterData(result);
        }
예제 #55
0
        public void Can_Deserialize_ActivityGoal_FromActivities()
        {
            string content = SampleDataHelper.GetContent("GetActivities.json");
            var deserializer = new JsonDotNetSerializer { RootProperty = "goals" };

            ActivityGoals goal = deserializer.Deserialize<ActivityGoals>(content);

            ValidateActivityGoals(goal);
        }
예제 #56
0
        public void Can_Deserialize_Friends_Single()
        {
            string content = SampleDataHelper.GetContent("GetFriends-Single.json");
            var deserializer = new JsonDotNetSerializer();

            List<UserProfile> friends = deserializer.GetFriends(content);

            Assert.IsNotNull(friends);
            ValidateSingleFriend(friends);
        }
예제 #57
0
        public void Can_Deserialize_Friends_None()
        {
            string content = SampleDataHelper.GetContent("GetFriends-None.json");
            var deserializer = new JsonDotNetSerializer();

            List<UserProfile> friends = deserializer.GetFriends(content);

            Assert.IsNotNull(friends);
            Assert.IsTrue(friends.Count == 0);
        }
예제 #58
0
        public void Can_Deserialize_Activity()
        {
            string content = SampleDataHelper.GetContent("GetActivities.json");
            var deserializer = new JsonDotNetSerializer();

            Activity activity = deserializer.Deserialize<Activity>(content);

            ValidateActivity(activity);
        }
예제 #59
0
        private bool IsTokenStale(string responseBody)
        {
            var errors = new JsonDotNetSerializer().ParseErrors(responseBody);

            return(errors.Any(error => error.ErrorType == "expired_token"));
        }
 public void DefaultValueCreated_JToken()
 {
     var serializer = new JsonDotNetSerializer();
     var defaultValue = serializer.Deserialize<TestClass>((JToken)null);
     Assert.AreEqual(default(TestClass), defaultValue);
 }