コード例 #1
0
ファイル: Pictures.cs プロジェクト: sachgits/Mute
        public async Task DogAsync()
        {
            var stream = await _dogs.GetDogPictureAsync();

            stream.Seek(0, SeekOrigin.Begin);

            await Context.Channel.SendFileAsync(stream, "dog.png");
        }
コード例 #2
0
        public async Task Service_Returns_DefaultValue()
        {
            var httpClient = new MockHttpClient(Responses);
            var dogs       = new DogPictureService(httpClient, "broken_dog_url");
            var stream     = await dogs.GetDogPictureAsync();

            var response = new StreamReader(stream).ReadToEnd();

            Assert.AreEqual("a picture of a default dog", response);
        }
コード例 #3
0
        public async Task Service_Returns_Dog()
        {
            var httpClient = new MockHttpClient(Responses);
            var dogs       = new DogPictureService(httpClient, "test_dog_url");
            var stream     = await dogs.GetDogPictureAsync();

            var actual = new StreamReader(stream).ReadToEnd();

            Assert.AreEqual("a picture of a dog", actual);
        }