public void TestFilterSearchQuery() { var query = new FilterSearchQuery(MetadataTag.Create("/private/filters/values/private-unread")); Assert.AreEqual("private-unread", query.Name); query = new FilterSearchQuery(MetadataTag.Create("/shared/filters/values/shared-unread")); Assert.AreEqual("shared-unread", query.Name); query = (FilterSearchQuery)SearchQuery.Filter("basic"); Assert.AreEqual("basic", query.Name); }
public void TestMetadataTag() { Assert.Throws <ArgumentNullException> (() => new MetadataTag(null)); Assert.Throws <ArgumentException> (() => new MetadataTag(string.Empty)); var tag1 = new MetadataTag("/dev/null"); var tag2 = new MetadataTag("/dev/null"); var tag3 = new MetadataTag("/opt/nope"); Assert.IsTrue(tag1.Equals(tag2), "Equals #1"); Assert.IsFalse(tag1.Equals(tag3), "Equals #2"); Assert.AreEqual(tag1.GetHashCode(), tag2.GetHashCode(), "GetHashCode #1"); Assert.AreNotEqual(tag1.GetHashCode(), tag3.GetHashCode(), "GetHashCode #2"); Assert.AreEqual(MetadataTag.PrivateComment, MetadataTag.Create(MetadataTag.PrivateComment.ToString())); Assert.AreEqual(MetadataTag.PrivateSpecialUse, MetadataTag.Create(MetadataTag.PrivateSpecialUse.ToString())); Assert.AreEqual(MetadataTag.SharedAdmin, MetadataTag.Create(MetadataTag.SharedAdmin.ToString())); Assert.AreEqual(MetadataTag.SharedComment, MetadataTag.Create(MetadataTag.SharedComment.ToString())); Assert.AreEqual(tag1, MetadataTag.Create(tag1.Id)); }
static SwfTagBase Create(SwfTagData tag_data) { var reader = new SwfStreamReader(tag_data.TagData); switch (tag_data.TagId) { // Display list case (int)SwfTagType.PlaceObject: return(PlaceObjectTag.Create(reader)); case (int)SwfTagType.PlaceObject2: return(PlaceObject2Tag.Create(reader)); case (int)SwfTagType.PlaceObject3: return(PlaceObject3Tag.Create(reader)); case (int)SwfTagType.RemoveObject: return(RemoveObjectTag.Create(reader)); case (int)SwfTagType.RemoveObject2: return(RemoveObject2Tag.Create(reader)); case (int)SwfTagType.ShowFrame: return(ShowFrameTag.Create(reader)); // Control case (int)SwfTagType.SetBackgroundColor: return(SetBackgroundColorTag.Create(reader)); case (int)SwfTagType.FrameLabel: return(FrameLabelTag.Create(reader)); case (int)SwfTagType.Protect: return(ProtectTag.Create(reader)); case (int)SwfTagType.End: return(EndTag.Create(reader)); case (int)SwfTagType.ExportAssets: return(ExportAssetsTag.Create(reader)); case (int)SwfTagType.ImportAssets: return(UnsupportedTag.Create(SwfTagType.ImportAssets)); case (int)SwfTagType.EnableDebugger: return(EnableDebuggerTag.Create(reader)); case (int)SwfTagType.EnableDebugger2: return(EnableDebugger2Tag.Create(reader)); case (int)SwfTagType.ScriptLimits: return(ScriptLimitsTag.Create(reader)); case (int)SwfTagType.SetTabIndex: return(UnsupportedTag.Create(SwfTagType.SetTabIndex)); case (int)SwfTagType.ImportAssets2: return(UnsupportedTag.Create(SwfTagType.ImportAssets2)); case (int)SwfTagType.SymbolClass: return(SymbolClassTag.Create(reader)); case (int)SwfTagType.Metadata: return(MetadataTag.Create(reader)); case (int)SwfTagType.DefineScalingGrid: return(UnsupportedTag.Create(SwfTagType.DefineScalingGrid)); case (int)SwfTagType.DefineSceneAndFrameLabelData: return(DefineSceneAndFrameLabelDataTag.Create(reader)); // Actions case (int)SwfTagType.DoAction: return(UnsupportedTag.Create(SwfTagType.DoAction)); case (int)SwfTagType.DoInitAction: return(UnsupportedTag.Create(SwfTagType.DoInitAction)); case (int)SwfTagType.DoABC: return(DoABCTag.Create(reader)); // Shape case (int)SwfTagType.DefineShape: return(DefineShapeTag.Create(reader)); case (int)SwfTagType.DefineShape2: return(DefineShape2Tag.Create(reader)); case (int)SwfTagType.DefineShape3: return(DefineShape3Tag.Create(reader)); case (int)SwfTagType.DefineShape4: return(DefineShape4Tag.Create(reader)); // Bitmaps case (int)SwfTagType.DefineBits: return(UnsupportedTag.Create(SwfTagType.DefineBits)); case (int)SwfTagType.JPEGTables: return(UnsupportedTag.Create(SwfTagType.JPEGTables)); case (int)SwfTagType.DefineBitsJPEG2: return(UnsupportedTag.Create(SwfTagType.DefineBitsJPEG2)); case (int)SwfTagType.DefineBitsJPEG3: return(UnsupportedTag.Create(SwfTagType.DefineBitsJPEG3)); case (int)SwfTagType.DefineBitsLossless: return(DefineBitsLosslessTag.Create(reader)); case (int)SwfTagType.DefineBitsLossless2: return(DefineBitsLossless2Tag.Create(reader)); case (int)SwfTagType.DefineBitsJPEG4: return(UnsupportedTag.Create(SwfTagType.DefineBitsJPEG4)); // Shape Morphing case (int)SwfTagType.DefineMorphShape: return(UnsupportedTag.Create(SwfTagType.DefineMorphShape)); case (int)SwfTagType.DefineMorphShape2: return(UnsupportedTag.Create(SwfTagType.DefineMorphShape2)); // Fonts and Text case (int)SwfTagType.DefineFont: return(UnsupportedTag.Create(SwfTagType.DefineFont)); case (int)SwfTagType.DefineFontInfo: return(UnsupportedTag.Create(SwfTagType.DefineFontInfo)); case (int)SwfTagType.DefineFontInfo2: return(UnsupportedTag.Create(SwfTagType.DefineFontInfo2)); case (int)SwfTagType.DefineFont2: return(UnsupportedTag.Create(SwfTagType.DefineFont2)); case (int)SwfTagType.DefineFont3: return(UnsupportedTag.Create(SwfTagType.DefineFont3)); case (int)SwfTagType.DefineFontAlignZones: return(UnsupportedTag.Create(SwfTagType.DefineFontAlignZones)); case (int)SwfTagType.DefineFontName: return(UnsupportedTag.Create(SwfTagType.DefineFontName)); case (int)SwfTagType.DefineText: return(UnsupportedTag.Create(SwfTagType.DefineText)); case (int)SwfTagType.DefineText2: return(UnsupportedTag.Create(SwfTagType.DefineText2)); case (int)SwfTagType.DefineEditText: return(UnsupportedTag.Create(SwfTagType.DefineEditText)); case (int)SwfTagType.CSMTextSettings: return(UnsupportedTag.Create(SwfTagType.CSMTextSettings)); case (int)SwfTagType.DefineFont4: return(UnsupportedTag.Create(SwfTagType.DefineFont4)); // Sounds case (int)SwfTagType.DefineSound: return(UnsupportedTag.Create(SwfTagType.DefineSound)); case (int)SwfTagType.StartSound: return(UnsupportedTag.Create(SwfTagType.StartSound)); case (int)SwfTagType.StartSound2: return(UnsupportedTag.Create(SwfTagType.StartSound2)); case (int)SwfTagType.SoundStreamHead: return(UnsupportedTag.Create(SwfTagType.SoundStreamHead)); case (int)SwfTagType.SoundStreamHead2: return(UnsupportedTag.Create(SwfTagType.SoundStreamHead2)); case (int)SwfTagType.SoundStreamBlock: return(UnsupportedTag.Create(SwfTagType.SoundStreamBlock)); // Buttons case (int)SwfTagType.DefineButton: return(UnsupportedTag.Create(SwfTagType.DefineButton)); case (int)SwfTagType.DefineButton2: return(UnsupportedTag.Create(SwfTagType.DefineButton2)); case (int)SwfTagType.DefineButtonCxform: return(UnsupportedTag.Create(SwfTagType.DefineButtonCxform)); case (int)SwfTagType.DefineButtonSound: return(UnsupportedTag.Create(SwfTagType.DefineButtonSound)); // Sprites and Movie Clips case (int)SwfTagType.DefineSprite: return(DefineSpriteTag.Create(reader)); // Video case (int)SwfTagType.DefineVideoStream: return(UnsupportedTag.Create(SwfTagType.DefineVideoStream)); case (int)SwfTagType.VideoFrame: return(UnsupportedTag.Create(SwfTagType.VideoFrame)); // Metadata case (int)SwfTagType.FileAttributes: return(FileAttributesTag.Create(reader)); case (int)SwfTagType.EnableTelemetry: return(EnableTelemetryTag.Create(reader)); case (int)SwfTagType.DefineBinaryData: return(DefineBinaryDataTag.Create(reader)); default: return(UnknownTag.Create(tag_data.TagId)); } }
public void TestArgumentExceptions() { Assert.Throws <ArgumentNullException> (() => SearchQuery.And(null, SearchQuery.All)); Assert.Throws <ArgumentNullException> (() => SearchQuery.And(SearchQuery.All, null)); Assert.Throws <ArgumentNullException> (() => SearchQuery.AnnotationsContain(null, AnnotationAttribute.Value, "value")); Assert.Throws <ArgumentNullException> (() => SearchQuery.AnnotationsContain(AnnotationEntry.AltSubject, null, "value")); Assert.Throws <ArgumentException> (() => SearchQuery.AnnotationsContain(AnnotationEntry.AltSubject, AnnotationAttribute.Size, "value")); Assert.Throws <ArgumentNullException> (() => SearchQuery.BccContains(null)); Assert.Throws <ArgumentException> (() => SearchQuery.BccContains(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.BodyContains(null)); Assert.Throws <ArgumentException> (() => SearchQuery.BodyContains(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.CcContains(null)); Assert.Throws <ArgumentException> (() => SearchQuery.CcContains(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.DoesNotHaveCustomFlag(null)); Assert.Throws <ArgumentException> (() => SearchQuery.DoesNotHaveCustomFlag(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.DoesNotHaveCustomFlags(null)); Assert.Throws <ArgumentException> (() => SearchQuery.DoesNotHaveCustomFlags(new string[0])); Assert.Throws <ArgumentException> (() => SearchQuery.DoesNotHaveFlags(MessageFlags.None)); Assert.Throws <ArgumentNullException> (() => SearchQuery.Filter(null)); Assert.Throws <ArgumentException> (() => SearchQuery.Filter(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.FromContains(null)); Assert.Throws <ArgumentException> (() => SearchQuery.FromContains(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.Fuzzy(null)); Assert.Throws <ArgumentNullException> (() => SearchQuery.GMailRawSearch(null)); Assert.Throws <ArgumentException> (() => SearchQuery.GMailRawSearch(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.HasCustomFlag(null)); Assert.Throws <ArgumentException> (() => SearchQuery.HasCustomFlag(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.HasCustomFlags(null)); Assert.Throws <ArgumentException> (() => SearchQuery.HasCustomFlags(new string[0])); Assert.Throws <ArgumentException> (() => SearchQuery.HasFlags(MessageFlags.None)); Assert.Throws <ArgumentNullException> (() => SearchQuery.HasKeyword(null)); Assert.Throws <ArgumentException> (() => SearchQuery.HasKeyword(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.HasKeywords(null)); Assert.Throws <ArgumentException> (() => SearchQuery.HasKeywords(new string[0])); Assert.Throws <ArgumentException> (() => SearchQuery.HasKeywords(new string[] { "keyword", null })); Assert.Throws <ArgumentException> (() => SearchQuery.NotFlags(MessageFlags.None)); Assert.Throws <ArgumentNullException> (() => SearchQuery.NotKeyword(null)); Assert.Throws <ArgumentException> (() => SearchQuery.NotKeyword(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.NotKeywords(null)); Assert.Throws <ArgumentException> (() => SearchQuery.NotKeywords(new string[0])); Assert.Throws <ArgumentException> (() => SearchQuery.NotKeywords(new string [] { "keyword", null })); Assert.Throws <ArgumentNullException> (() => SearchQuery.HasGMailLabel(null)); Assert.Throws <ArgumentException> (() => SearchQuery.HasGMailLabel(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.HeaderContains(null, "text")); Assert.Throws <ArgumentException> (() => SearchQuery.HeaderContains(string.Empty, "text")); Assert.Throws <ArgumentNullException> (() => SearchQuery.HeaderContains("name", null)); Assert.Throws <ArgumentOutOfRangeException> (() => SearchQuery.LargerThan(-1)); Assert.Throws <ArgumentNullException> (() => SearchQuery.MessageContains(null)); Assert.Throws <ArgumentException> (() => SearchQuery.MessageContains(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.Not(null)); Assert.Throws <ArgumentOutOfRangeException> (() => SearchQuery.OlderThan(-1)); Assert.Throws <ArgumentNullException> (() => SearchQuery.Or(null, SearchQuery.All)); Assert.Throws <ArgumentNullException> (() => SearchQuery.Or(SearchQuery.All, null)); Assert.Throws <ArgumentOutOfRangeException> (() => SearchQuery.SmallerThan(-1)); Assert.Throws <ArgumentNullException> (() => SearchQuery.SubjectContains(null)); Assert.Throws <ArgumentException> (() => SearchQuery.SubjectContains(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.ToContains(null)); Assert.Throws <ArgumentException> (() => SearchQuery.ToContains(string.Empty)); Assert.Throws <ArgumentOutOfRangeException> (() => SearchQuery.YoungerThan(-1)); Assert.Throws <ArgumentNullException> (() => SearchQuery.All.And(null)); Assert.Throws <ArgumentNullException> (() => SearchQuery.All.Or(null)); Assert.Throws <ArgumentNullException> (() => new BinarySearchQuery(SearchTerm.And, null, SearchQuery.All)); Assert.Throws <ArgumentNullException> (() => new BinarySearchQuery(SearchTerm.And, SearchQuery.All, null)); Assert.Throws <ArgumentNullException> (() => new FilterSearchQuery(null)); Assert.Throws <ArgumentException> (() => new FilterSearchQuery(string.Empty)); Assert.Throws <ArgumentException> (() => new FilterSearchQuery(MetadataTag.Create("/dev/null"))); Assert.Throws <ArgumentNullException> (() => new HeaderSearchQuery(null, "text")); Assert.Throws <ArgumentException> (() => new HeaderSearchQuery(string.Empty, "text")); Assert.Throws <ArgumentNullException> (() => new HeaderSearchQuery("name", null)); Assert.Throws <ArgumentNullException> (() => new TextSearchQuery(SearchTerm.BodyContains, null)); Assert.Throws <ArgumentNullException> (() => new UidSearchQuery(null)); Assert.Throws <ArgumentException> (() => new UidSearchQuery(new UniqueIdSet())); Assert.Throws <ArgumentException> (() => new UidSearchQuery(UniqueId.Invalid)); Assert.Throws <ArgumentNullException> (() => new UnarySearchQuery(SearchTerm.Not, null)); }