Esempio n. 1
0
        public void CreateAndEqualTest()
        {
            var atAll = SendingMessage.AtAll();

            Assert.Equal("[CQ:at,qq=all]", atAll.Raw);

            //var section = new Section(Section.MusicType, ("type", "cus"), ("source", "test"));
            var section = new Section(Section.MusicType, new Dictionary <string, string>
            {
                { "type", "cus" },
                { "source", "test" },
            });
            var section2 = new Section(Section.MusicType, ("source", "test"), ("type", "cus"));
            var json     = JsonConvert.SerializeObject(section);
            var jObj     = JsonConvert.DeserializeObject <JObject>(json);

            Assert.Equal(Section.MusicType, jObj["type"].ToObject <string>());
            var desSection = jObj.ToObject <Section>();

            Assert.Equal(section, desSection);
            Assert.Equal(section, section2);
            Assert.Equal(desSection, section2);
            Assert.Equal(section.GetHashCode(), desSection.GetHashCode());
            Assert.Equal(section.GetHashCode(), section2.GetHashCode());
            Assert.Equal(desSection.GetHashCode(), section2.GetHashCode());
            Assert.NotEqual(section.Raw, section2.Raw);
        }
        public void Ctor()
        {
            string message = "123[";
            string raw     = "123&#91;";
            var    msg1    = new SendingMessage(message);

            Assert.Equal(raw, msg1.Raw);
            //Assert.Equal(message, msg1.ToString());

            var     atSection          = new Section("at", ("qq", "all"));
            var     atMsg              = SendingMessage.AtAll();
            Section atMsgSingleSection = atMsg.Sections.Single();

            Assert.Equal(atSection, atMsgSingleSection);
        }