Ejemplo n.º 1
0
        public void OnMessage_モードがpost()
        {
            // arrange
            Message actMessage = null;

            target.add_OnNewMessage(message => {
                actMessage = message;
            });

            var expSummary = new Summary(DynamicJson_Accessor.Serialize(new {
                room     = "room",
                listener = 1,
                viewer   = 1
            }));
            var expMessage = this.CreateMessage(1, "", "hoge", "comment", new DateTime(2000, 1, 1), false, false);

            // act
            var client = (MoqSocketIO)this.target.client;

            client.TriggerOnMessage(new {
                ret         = true,
                mode        = "post",
                listener    = expSummary.Listener,
                viewer      = expSummary.PageView,
                comment_num = expMessage.Number,
                name        = expMessage.Name,
                message     = expMessage.Comment,
                time        = JavaScriptTime_Accessor.ToDouble(expMessage.PostTime, TimeZoneKind.Japan),
                auth        = false,
                is_ban      = false,
            });

            // assert
            Assert.AreEqual(expMessage, actMessage);
        }
Ejemplo n.º 2
0
        public void ParseMessage_正常()
        {
            // arrange
            var time       = new DateTime(2000, 1, 1);
            var message1   = this.CreateMessage(1, "", "hoge", "comment", time, true, false);
            var message2   = this.CreateMessage(1, "", "fuga", "comment", time, true, false);
            var message3   = this.CreateMessage(1, "", "piyo", "comment", time, true, false);
            var list       = new Message[] { message1, message2, message3 };
            var jsonString = DynamicJson_Accessor.Serialize(new {
                comments = list.Select(item => new {
                    comment_num = item.Number,
                    message     = item.Comment,
                    html        = "",
                    name        = item.Name,
                    time        = JavaScriptTime_Accessor.ToDouble(item.PostTime, TimeZoneKind.Japan),
                    is_ban      = item.IsBan,
                    auth        = item.IsAuth,
                }),
            });

            // act
            var actual = target.ParseMessage(jsonString);

            // assert
            Assert.AreEqual(message1, actual.ElementAt(0));
            Assert.AreEqual(message2, actual.ElementAt(1));
            Assert.AreEqual(message3, actual.ElementAt(2));
        }
Ejemplo n.º 3
0
        public void ToDouble_小数点以下切り捨て()
        {
            // arrange
            var date = new DateTime(2000, 1, 1, 0, 0, 0, 999);

            // act
            var act = JavaScriptTime_Accessor.ToDouble(date, TimeZoneKind.Japan);

            // assert
            Assert.AreEqual(946652400000, act);
        }
Ejemplo n.º 4
0
        private Message CreateMessage(Int32 number, String id, String name, String comment, DateTime time, Boolean auth, Boolean isBan)
        {
            var json = DynamicJson_Accessor.Serialize(new {
                comment_num = number,
                user_id     = id,
                name        = name,
                message     = comment,
                auth        = auth,
                is_ban      = isBan,
                time        = JavaScriptTime_Accessor.ToDouble(time),
            });

            return(new Message(json));
        }