示例#1
0
        public async Task Given_ExpanderResponse_When_AddHitCountAsync_Invoked_Then_It_Should_Return_Result(int hitCount)
        {
            var shortener = new Mock <IShortenerService>();
            var expander  = new Mock <IExpanderService>();
            var response  = new ExpanderResponse()
            {
                HitCount = hitCount
            };

            var url = new Url(shortener.Object, expander.Object);

            typeof(Url).GetProperty("ExpanderResponse", BindingFlags.Public | BindingFlags.Instance)
            .SetValue(url, response);
            typeof(Url).GetProperty("HitCount", BindingFlags.Public | BindingFlags.Instance)
            .SetValue(url, hitCount);

            var result = await url.AddHitCountAsync <ExpanderResponse>().ConfigureAwait(false);

            result.Should().BeOfType <Url>()
            .And.BeAssignableTo <IUrl>();

            url.HitCount.Should().Be(hitCount + 1);
            url.ExpanderResponse.HitCount.Should().Be(hitCount + 1);
        }