private static Mask TestFlag(Lens flag, Mask target) { target = flag.To(false, target); Assert.False(flag.From(target)); target = flag.To(true, target); Assert.True(flag.From(target)); target = flag.To(false, target); Assert.False(flag.From(target)); target = flag.To(true, target); Assert.True(flag.From(target)); return(target); }
protected override void TestImpl() { var log = new Lens(t => t.Log, (v, t) => { t.Log = v; return(t); }); var warning = new Lens(t => t.Warning, (v, t) => { t.Warning = v; return(t); }); var error = new Lens(t => t.Error, (v, t) => { t.Error = v; return(t); }); var assert = new Lens(t => t.Assert, (v, t) => { t.Assert = v; return(t); }); var exception = new Lens(t => t.Exception, (v, t) => { t.Exception = v; return(t); }); var all = new[] { log, warning, error, assert, exception }; var target = new Mask(); target.SetAllTrue(); Assert.True(all.All(l => l.From(target))); target.SetAllFalse(); Assert.False(all.Any(l => l.From(target))); all.ToList().ForEach(l => target = TestFlag(l, target)); Assert.True(all.All(l => l.From(target))); }
protected override void TestImpl() { var message = "message"; var stacktrace = "stacktrace"; var time = 1234; var scene = "scene"; var sample = new Sample(time, scene); var target = new Stash(); var organizer = target.Organizer; var loop = 5; var logTypes = new[] { LogType.Log, LogType.Warning, LogType.Error, }; for (var i = 0; i != loop; ++i) { logTypes.ToList().ForEach(t => { var rawLog = new RawLog(t, message, stacktrace); target.Add(rawLog, sample); }); } var allCount = loop * logTypes.Length; Assert.Equals(target.All().Count, allCount); { var mask = new Mask(); mask.SetAllTrue(); var logs = organizer.Filter(mask); Assert.Equals(logs.Count, allCount); } { var mask = new Mask(); mask.SetAllFalse(); var logs = organizer.Filter(mask); Assert.Equals(logs.Count, 0); } { var mask = new Mask(); mask.Warning = true; mask.Assert = true; Assert.Equals(organizer.Filter(mask).Count, loop * 1); mask.Log = true; Assert.Equals(organizer.Filter(mask).Count, loop * 2); } { var mask = new Mask(); mask.Log = true; var logs = organizer.Filter(mask); Assert.Equals(logs.Count, loop); var firstLog = logs[0]; Assert.Equals(firstLog.Type, logTypes[0]); Assert.Equals(firstLog.Message, message); Assert.Equals(firstLog.Stacktrace, stacktrace); Assert.Equals(firstLog.Sample.Scene, scene); Assert.Equals(firstLog.Sample.Time, time); } }