Пример #1
0
        public void ShouldFailUsersWhenApiUnavailable()
        {
            var rc = new RecentChange("1.2.3.4");

            // act, assert
            Assert.Throws <InvalidOperationException>(() => rc.GetUserGroups());
        }
Пример #2
0
        public void ShouldGetIpGroups()
        {
            var rc    = new RecentChange("1.2.3.4");
            var mwapi = new Mock <IMediaWikiApi>();

            rc.MediaWikiApi = mwapi.Object;

            var expected = new[] { "*" };

            mwapi.Setup(x => x.GetUserGroups("1.2.3.4")).Returns(expected);

            // act
            var result = rc.GetUserGroups();

            // assert
            Assert.AreEqual(expected, result);
            mwapi.Verify(x => x.GetUserGroups(It.IsAny <string>()), Times.Once());
        }