Пример #1
0
        public async Task TestGetCollectionAsync()
        {
            var actual = await JsonPlaceholderClient.Posts.GetAsync();

            Assert.Equal(HttpStatusCode.OK, actual.StatusCode);

            var expectedCount = 100;
            var actualCount   = actual.Data.Count();

            Assert.Equal(expectedCount, actualCount);

            var expectedFirst = new PostDto
            {
                Id     = 1,
                UserId = 1,
                Title  = "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
                Body   = "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto",
            };

            var actualFirst = actual.Data.First();

            AssertUtilities.Equal(expectedFirst, actualFirst);

            var expectedLast = new PostDto
            {
                Id     = 100,
                UserId = 10,
                Title  = "at nam consequatur ea labore ea harum",
                Body   = "cupiditate quo est a modi nesciunt soluta\nipsa voluptas error itaque dicta in\nautem qui minus magnam et distinctio eum\naccusamus ratione error aut",
            };

            var actualLast = actual.Data.Last();

            AssertUtilities.Equal(expectedLast, actualLast);
        }
Пример #2
0
        public async Task TestGetExportsCsvAsync()
        {
            var csvSerializationService = new CsvSerializer();

            var expectedDtos = new List <CustomerExportGetCollectionResponse>
            {
                new CustomerExportGetCollectionResponse
                {
                    Id        = 1,
                    UserName  = "******",
                    FirstName = "John",
                    LastName  = "Smith",
                },

                new CustomerExportGetCollectionResponse
                {
                    Id        = 2,
                    UserName  = "******",
                    FirstName = "Mary",
                    LastName  = "McDonald",
                }
            };

            var expected = csvSerializationService.Serialize(expectedDtos);

            var actual = await Fixture.Customers.GetCsvExportsAsync();

            Assert.Equal(HttpStatusCode.OK, actual.StatusCode);

            AssertUtilities.Equal(expected, actual.ContentString);
        }
Пример #3
0
        public async Task TestGetAllAsync()
        {
            var expected = new CustomerGetAllResponse
            {
                Records = new List <CustomerGetAllRecordResponse>
                {
                    new CustomerGetAllRecordResponse
                    {
                        Id               = 1,
                        UserName         = "******",
                        FirstName        = "John",
                        LastName         = "Smith",
                        CreatedDateTime  = new DateTime(2019, 1, 1, 8, 20, 36),
                        ModifiedDateTime = new DateTime(2019, 1, 2, 9, 30, 42),
                    },

                    new CustomerGetAllRecordResponse
                    {
                        Id               = 2,
                        UserName         = "******",
                        FirstName        = "Mary",
                        LastName         = "McDonald",
                        CreatedDateTime  = new DateTime(2018, 7, 4, 14, 40, 12),
                        ModifiedDateTime = new DateTime(2018, 9, 8, 18, 50, 18),
                    }
                }
            };

            var actual = await Fixture.Customers.GetAllAsync();

            Assert.Equal(HttpStatusCode.OK, actual.StatusCode);

            AssertUtilities.Equal(expected, actual.Data);
        }
Пример #4
0
        public void TestDeserializeGeneric()
        {
            var csvSerializer = new CsvSerializer();

            var content = CreateContent();

            var expected = CreateRecords();

            var actual = csvSerializer.Deserialize <List <Customer> >(content);

            AssertUtilities.Equal(expected, actual);
        }
Пример #5
0
        public void TestSerializeEnumerable()
        {
            var csvSerializer = new CsvSerializer();

            var records = CreateRecords();

            var expected = CreateContent();

            var actual = csvSerializer.SerializeEnumerable(records);

            AssertUtilities.Equal(expected, actual);
        }
Пример #6
0
        public void TestSerializeTyped()
        {
            var csvSerializer = new CsvSerializer();

            var records = CreateRecords();

            var expected = CreateContent();

            var actual = csvSerializer.Serialize(records, typeof(Customer));

            AssertUtilities.Equal(expected, actual);
        }
Пример #7
0
        public void TestDeserializeTyped()
        {
            var csvSerializer = new CsvSerializer();

            var content = CreateContent();

            var expected = CreateRecords();

            var actual = csvSerializer.Deserialize(content, typeof(List <Customer>));

            AssertUtilities.Equal(expected, actual);

            Assert.IsType <List <Customer> >(actual);
        }
Пример #8
0
        public async Task TestGetAsync()
        {
            var expected = new List <string>
            {
                "value1",
                "value2"
            };

            var actual = await Fixture.Values.GetAllAsync();

            Assert.Equal(HttpStatusCode.OK, actual.StatusCode);

            AssertUtilities.Equal(expected, actual.Data);
        }
Пример #9
0
        public async Task TestGetAsync()
        {
            var expected = new PostDto
            {
                Id     = 1,
                UserId = 1,
                Title  = "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
                Body   = "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto",
            };

            var actual = await JsonPlaceholderClient.Posts.GetAsync(1);

            Assert.Equal(HttpStatusCode.OK, actual.StatusCode);

            AssertUtilities.Equal(expected, actual.Data);
        }
Пример #10
0
        public async Task TestPutAsync()
        {
            var expected = await JsonPlaceholderClient.Posts.GetAsync(7);

            Assert.Equal(HttpStatusCode.OK, expected.StatusCode);

            var expectedContent = expected.Data;

            expectedContent.UserId = 10;
            expectedContent.Title  = "Some Title";
            expectedContent.Body   = "Some Body";

            var actual = await JsonPlaceholderClient.Posts.PutAsync(7, expectedContent);

            Assert.Equal(HttpStatusCode.OK, actual.StatusCode);

            var actualContent = actual.Data;

            AssertUtilities.Equal(expectedContent, actualContent);
        }
Пример #11
0
        public async Task TestPatchAsync()
        {
            var expected = await JsonPlaceholderClient.Posts.GetAsync(5);

            Assert.Equal(HttpStatusCode.OK, expected.StatusCode);

            var expectedContent = expected.Data;

            expectedContent.Title = "Some Title";

            var request = new PostDto
            {
                Title = "Some Title",
            };

            var actual = await JsonPlaceholderClient.Posts.PutAsync(5, request);

            Assert.Equal(HttpStatusCode.OK, actual.StatusCode);

            var actualContent = actual.Data;

            AssertUtilities.Equal(expectedContent, actualContent);
        }