예제 #1
0
        public void CavetubeMainTest2_RoomIdNotFound()
        {
            var clientFactory = new MockCavetubeClientFactory();
            var mockClient    = clientFactory.MockCavetubeClient;
            var authFactory   = new MockCavetubeAuthFactory();
            var mockAuth      = authFactory.MockCavetubeAuth;
            var pso2Factory   = new MockPso2LogWatcherFactory();
            var mockPso2      = pso2Factory.MockPso2LogWatcher;

            var summary = new SummaryWrapper();
            //summary.RoomId = "roomid";
            var manualEvent = new ManualResetEvent(false);
            var check       = true;

            mockAuth.Setup(a => a.Login(It.IsAny <string>(), It.IsAny <string>())).Returns("apikey");
            mockClient.Setup(cl => cl.JoinRoom(It.IsAny <string>())).Raises(m => m.OnJoin += null, "roomid");
            mockClient.Setup(cl => cl.LeaveRoom()).Raises(m => m.OnLeave += null, "roomid");
            mockClient.Setup(cl => cl.GetSummary(It.IsAny <string>())).Returns(summary);
            mockClient.Setup(cl => cl.PostComment(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Callback <string, string, string>((name, message, apikey) =>
            {
                check = false;
                manualEvent.Set();
                Assert.AreEqual("someone", name);
                Assert.AreEqual("message", message);
                Assert.AreEqual("apikey", apikey);
            });

            var msg = new Pso2LogEventArgs();

            msg.From    = "someone";
            msg.SendTo  = "GUILD";
            msg.Message = "message";
            mockPso2.Setup(pso2 => pso2.Start()).Raises(pso2 => pso2.Pso2LogEvent += null, msg);

            var ex = Assert.Throws <ApplicationException>(() =>
            {
                Pso2LogSender.CavetubeMain(authFactory, clientFactory, pso2Factory, () =>
                {
                    check = false;
                    manualEvent.WaitOne();
                });
            });

            Assert.AreEqual("部屋IDの取得に失敗しました", ex.Message);

            Assert.True(check);
        }
예제 #2
0
        public void LivetubeMainTest3_StreamIdNotFound()
        {
            var clientFactory = new MockLivetubeClientFactory();
            var mockClient    = clientFactory.MockLivetubeClient;
            var pso2Factory   = new MockPso2LogWatcherFactory();
            var mockPso2      = pso2Factory.MockPso2LogWatcher;

            var manualEvent = new ManualResetEvent(false);
            var check       = true;

            mockClient.Setup(cl => cl.FindCurrentBroadcasting(It.IsAny <string>())).Returns("http://livetube.cc/someone/sometitle");
            mockClient.Setup(cl => cl.FindStream(It.IsAny <string>())).Returns((String)null);
            mockClient.Setup(cl => cl.PostComment(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Callback <string, string, string>((stream, user, comment) =>
            {
                check = false;
                manualEvent.Set();
                Assert.AreEqual("stream_id", stream);
                Assert.AreEqual("someone", user);
                Assert.AreEqual("message", comment);
            });

            var msg = new Pso2LogEventArgs();

            msg.From    = "someone";
            msg.SendTo  = "GUILD";
            msg.Message = "message";
            mockPso2.Setup(pso2 => pso2.Start()).Raises(pso2 => pso2.Pso2LogEvent += null, msg);

            var ex = Assert.Throws <ApplicationException>(() =>
            {
                Pso2LogSender.LivetubeMain(clientFactory, pso2Factory, () =>
                {
                    check = false;
                    manualEvent.WaitOne();
                });
            });

            Assert.AreEqual("ストリームの取得に失敗しました", ex.Message);

            Assert.True(check);
        }