public void LoadResponse(ref MockHttpResponse response, ref MockHttpContent content, ResponseType responseType)
 {
     if (response == null)
     {
         throw new ArgumentNullException(nameof(response), "response cannot be null in BeastSaberResponseTemplate.LoadResponse.");
     }
     if (content == null)
     {
         throw new ArgumentNullException(nameof(content), "content cannot be null in BeastSaberResponseTemplate.LoadResponse.");
     }
 }
Esempio n. 2
0
        public void ReadAsStreamAsync_Test()
        {
            var dataDirectory = @"Data\BeastSaber";
            var jsonFile      = Path.Combine(dataDirectory, "bookmarked_by_zingabopp1.json");

            using (var mockContent = new MockHttpContent(jsonFile))
                using (var actualStream = mockContent.ReadAsStreamAsync().Result)
                    using (var expectedStream = File.OpenRead(jsonFile))
                    {
                        Assert.AreEqual(expectedStream.Length, actualStream.Length);
                    }
        }
Esempio n. 3
0
        public void ReadAsStringAsync_Test()
        {
            var dataDirectory = @"Data\BeastSaber";
            var jsonFile      = Path.Combine(dataDirectory, "bookmarked_by_zingabopp1.json");

            using (var mockContent = new MockHttpContent(jsonFile))
            {
                var expectedString = File.ReadAllText(mockContent.FileSourcePath);
                var actualString   = mockContent.ReadAsStringAsync().Result;
                Assert.AreEqual(expectedString, actualString);
            }
        }
Esempio n. 4
0
        public void ReadAsFile_Test()
        {
            var dataDirectory = @"Data\BeastSaber";
            var jsonFile      = Path.Combine(dataDirectory, "bookmarked_by_zingabopp1.json");

            using (var mockContent = new MockHttpContent(jsonFile))
            {
                var expectedString = File.ReadAllText(mockContent.FileSourcePath);
                var dirPath        = new DirectoryInfo(DownloadPath);
                var destPath       = Path.Combine(dirPath.FullName, Path.GetFileName(mockContent.FileSourcePath));
                mockContent.ReadAsFileAsync(destPath, true).Wait();
                var actualString = mockContent.ReadAsStringAsync().Result;
                Assert.AreEqual(expectedString, actualString);
                AssertAsync.ThrowsExceptionAsync <InvalidOperationException>(async() => await mockContent.ReadAsFileAsync(destPath, false).ConfigureAwait(false)).Wait();
            }
        }
Esempio n. 5
0
        public void ContentType_Test()
        {
            var dataDirectory = @"Data\BeastSaber";
            var jsonFile      = Path.Combine(dataDirectory, "bookmarked_by_zingabopp1.json");
            var xmlFile       = Path.Combine(dataDirectory, "followings1.xml");

            using (var mockContent = new MockHttpContent(jsonFile))
            {
                var expectedContentType = @"application/json";
                Assert.AreEqual(expectedContentType, mockContent.ContentType);
            }
            using (var mockContent = new MockHttpContent(xmlFile))
            {
                var expectedContentType = @"text/xml";
                Assert.AreEqual(expectedContentType, mockContent.ContentType);
            }
        }
Esempio n. 6
0
        public void ReadAsByteArrayAsync_Test()
        {
            var dataDirectory = @"Data\BeastSaber";
            var jsonFile      = Path.Combine(dataDirectory, "bookmarked_by_zingabopp1.json");

            using (var mockContent = new MockHttpContent(jsonFile))
            {
                var  expectedArray = File.ReadAllBytes(mockContent.FileSourcePath);
                var  actualArray   = mockContent.ReadAsByteArrayAsync().Result;
                bool notEqual      = false;
                Assert.AreEqual(expectedArray.LongLength, actualArray.LongLength);
                Assert.IsTrue(actualArray.LongLength > 0);
                for (long i = 0; i < expectedArray.LongLength; i++)
                {
                    if (expectedArray[i] != actualArray[i])
                    {
                        notEqual = true;
                    }
                }
                Assert.IsFalse(notEqual);
            }
        }