예제 #1
0
        public void Run()
        {
            Console.WriteLine("Press 'Enter' to send a message. To exit, Ctrl + C");

            while (true)
            {
                var read = Console.ReadLine();
                LogMessage message = null;
                read = string.IsNullOrEmpty(read) ? "info Info Message" : read;

                if (read.IndexOf(" ") < 0)
                    read += " Log Message";

                var type = read.Substring(0, read.IndexOf(" "));
                var payload = read.Substring(read.IndexOf(" ") + 1);

                switch (type.ToLower())
                {
                    case "warn":
                        message = new Warn();
                        break;
                    case "error":
                        message = new Error();
                        break;
                    default:
                        message = new Info();
                        break;
                }

                message.Message = payload;
                Bus.Send(message);
            }
        }
예제 #2
0
 public void WarnIf_Passes_ActualAndConstraint()
 {
     Warn.If(2 + 2, Is.Not.EqualTo(4));
 }
예제 #3
0
        public void WarnIf_Passes_BooleanLambdaWithWithMessageStringFunc()
        {
            Func <string> getExceptionMessage = () => string.Format("Not Equal to {0}", 4);

            Warn.If(() => 2 + 2 != 4, getExceptionMessage);
        }
예제 #4
0
 public void WarnUnless_Passes_BooleanLambdaWithMessageAndArgs()
 {
     Warn.Unless(() => 2 + 2 == 4, "Not Equal to {0}", 4);
 }
예제 #5
0
 public void WarnUnless_Passes_BooleanLambdaWithMessage()
 {
     Warn.Unless(() => 2 + 2 == 4, "Not Equal");
 }
 public void TestCaseWarnsThreeTimes(int a, int b, int answer)
 {
     Warn.Unless(a + b, Is.EqualTo(answer), "Bad sum");
     Warn.Unless(a - b, Is.EqualTo(answer), "Bad difference");
     Warn.Unless(a * b, Is.EqualTo(answer), "Bad product");
 }
예제 #7
0
 public void PerformanceTests(IEnumerable values)
 {
     Warn.Unless(() => CollectionAssert.AllItemsAreUnique(values), HelperConstraints.HasMaxTime(100));
 }
 public override void Visit(Warn expression)
 {
     terminal.Peek().AppendFormat("/Warn<'{0}'>", Regex.Replace(expression.Message, "'", @"\'"));
 }
예제 #9
0
 public void WarnUnless_Fails_DelegateAndConstraint()
 {
     Warn.Unless(new ActualValueDelegate <int>(ReturnsFive), Is.EqualTo(4));
 }
예제 #10
0
 public void WarnUnless_Passes_BooleanWithMessage()
 {
     Warn.Unless(2 + 2 == 4, "Not Equal");
 }
예제 #11
0
        public void WarnIf_Fails_ActualLambdaAndConstraintWithMessageStringFunc()
        {
            Func <string> getExceptionMessage = () => "Should be 5";

            Warn.If(() => 2 + 2, Is.Not.EqualTo(5), getExceptionMessage);
        }
예제 #12
0
 public void WarnIf_Fails_ActualLambdaAndConstraintWithMessageAndArgs()
 {
     Warn.If(() => 2 + 2, Is.Not.EqualTo(5), "Should be {0}", 5);
 }
예제 #13
0
 public void WarnIf_Fails_ActualLambdaAndConstraintWithMessage()
 {
     Warn.If(() => 2 + 2, Is.Not.EqualTo(5), "Error");
 }
예제 #14
0
 public void WarnUnless_Fails_ActualLambdaAndConstraintWithMessage()
 {
     Warn.Unless(() => 2 + 2, Is.EqualTo(5), "Error");
 }
예제 #15
0
 public void WarnIf_Fails_ActualLambdaAndConstraint()
 {
     Warn.If(() => 2 + 2, Is.Not.EqualTo(5));
 }
예제 #16
0
 public void WarnUnless_Fails_ActualLambdaAndConstraint()
 {
     Warn.Unless(() => 2 + 2, Is.EqualTo(5));
 }
예제 #17
0
 public void WarnUnless_Passes_BooleanLambda()
 {
     Warn.Unless(() => 2 + 2 == 4);
 }
예제 #18
0
 public void WarnIf_Fails_DelegateAndConstraint()
 {
     Warn.If(new ActualValueDelegate <int>(ReturnsFive), Is.Not.EqualTo(4));
 }
예제 #19
0
        protected Texture getTexture(string filepath)
        {
            Texture t = null;

            if (filepath[0] == '*') //this is an embedded texture
            {
                string textureIndexStr = filepath.TrimStart('*');
                int    index           = Convert.ToInt32(textureIndexStr);
                if (index >= myScene.TextureCount)
                {
                    Warn.print("texture index({0}) is out of range({1})", index, myScene.TextureCount);
                    return(null);
                }

                EmbeddedTexture texData = myScene.Textures[index];
                if (texData != null)
                {
                    if (texData.IsCompressed)
                    {
                        byte[] bytes = texData.CompressedData;
                        switch (texData.CompressedFormatHint)
                        {
                        case "png": //fallthrough
                        case "jpg":
                            t = new Texture();
                            Stream stream = new MemoryStream(texData.CompressedData, false);
                            t.loadFromStream(stream);
                            break;

                        case "dds":
                            Warn.print("DDS files not supported yet");
                            break;

                        default:
                            Warn.print("Unkown compressed file format {0}", texData.CompressedFormatHint);
                            break;
                        }
                    }
                    else
                    {
                        byte[] bytes = new byte[texData.Width * texData.Height * 4];
                        for (int i = 0; i < texData.Height; i++)
                        {
                            for (int j = 0; i < texData.Width; i++)
                            {
                                bytes[j + (i * texData.Width) + 0] = texData.NonCompressedData[j + (i * texData.Width)].R;
                                bytes[j + (i * texData.Width) + 1] = texData.NonCompressedData[j + (i * texData.Width)].G;
                                bytes[j + (i * texData.Width) + 2] = texData.NonCompressedData[j + (i * texData.Width)].B;
                                bytes[j + (i * texData.Width) + 3] = texData.NonCompressedData[j + (i * texData.Width)].A;
                            }
                        }

                        Texture.PixelData pData = new Texture.PixelData();
                        pData.data        = bytes;
                        pData.dataType    = PixelType.Byte;
                        pData.pixelFormat = PixelFormat.Rgba;
                        t = new Texture(texData.Width, texData.Height, PixelInternalFormat.Rgba8, pData, true);
                    }
                }
            }
            else //just a path name
            {
                string            textureName = filepath.TrimStart('/');
                TextureDescriptor td          = new TextureDescriptor(Path.Combine(myRootPath, textureName), true);
                t = myResourceManager.getResource(td) as Texture;

                if (t == null)
                {
                    Warn.print("Failed to load texture {0}", filepath);
                }
            }

            return(t);
        }
예제 #20
0
 public void WarnIf_Fails_DelegateAndConstraintWithMessage()
 {
     Warn.If(new ActualValueDelegate <int>(ReturnsFive), Is.Not.EqualTo(4), "Error");
 }
 public void TestCaseWarns(int a, int b, int sum)
 {
     Warn.Unless(a + b, Is.EqualTo(sum));
 }
예제 #22
0
 public void WarnIf_Fails_DelegateAndConstraintWithMessageAndArgs()
 {
     Warn.If(new ActualValueDelegate <int>(ReturnsFive), Is.Not.EqualTo(4), "Should be {0}", 4);
 }
예제 #23
0
 public void WarnIf_Passes_BooleanLambda()
 {
     Warn.If(() => 2 + 2 != 4);
 }
예제 #24
0
        public void WarnIf_Fails_DelegateAndConstraintWithMessageStringFunc()
        {
            Func <string> getExceptionMessage = () => "Should be 4";

            Warn.If(new ActualValueDelegate <int>(ReturnsFive), Is.Not.EqualTo(4), getExceptionMessage);
        }
예제 #25
0
 public void WarnIf_Passes_BooleanLambdaWithMessage()
 {
     Warn.If(() => 2 + 2 != 4, "Not Equal");
 }
예제 #26
0
 public void WarnUnless_Fails_Async()
 {
     Warn.Unless(async() => await One(), Is.EqualTo(2));
 }
예제 #27
0
 public void WarnIf_Passes_BooleanLambdaWithMessageAndArgs()
 {
     Warn.If(() => 2 + 2 != 4, "Not Equal to {0}", 4);
 }
예제 #28
0
 public void WarnIf_Passes_BooleanWithMessage()
 {
     Warn.If(2 + 2 != 4, "Not Equal");
 }
예제 #29
0
 public void WarnUnless_Passes_ActualAndConstraint()
 {
     Warn.Unless(2 + 2, Is.EqualTo(4));
 }
예제 #30
0
 public void WarnIf_Fails_Async()
 {
     Warn.If(async() => await One(), Is.Not.EqualTo(2));
 }
예제 #31
0
        public void WarnUnless_Passes_BooleanWithMessageStringFunc()
        {
            Func <string> getExceptionMessage = () => string.Format("Not Equal to {0}", 4);

            Warn.Unless(2 + 2 == 4, getExceptionMessage);
        }
예제 #32
0
 public Variables(IList<VariableResource> destination, Warn writeWarning)
 {
     _variableSet = destination;
     _writeWarning = writeWarning;
 }