コード例 #1
0
        public void EnvironmentVariablesToToolTaskInvalid3()
        {
            MyTool task = new MyTool();

            task.BuildEngine          = new MockEngine();
            task.EnvironmentVariables = new string[] { "=a;b=c" };
            bool result = task.Execute();

            result.ShouldBe(false);
            task.ExecuteCalled.ShouldBe(false);
        }
コード例 #2
0
ファイル: ToolTask_Tests.cs プロジェクト: ststeiger/msbuild
        public void EnvironmentVariablesToToolTaskInvalid3()
        {
            MyTool task = new MyTool();

            task.BuildEngine          = new MockEngine();
            task.EnvironmentVariables = new string[] { "=a;b=c" };
            bool result = task.Execute();

            Assert.Equal(false, result);
            Assert.Equal(false, task.ExecuteCalled);
        }
コード例 #3
0
 private void dışarıAktarToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         MyTool.Json <Context>(MyContext, new SaveFileDialog());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #4
0
ファイル: frmGiaoVien.cs プロジェクト: minhtinhtinh/DA_UDQL
        private void btnExportQuestion_Click(object sender, EventArgs e)
        {
            List <Question> lst = new List <Question>();

            using (var db = new dbQLThiTracNghiemDataContext())
            {
                lst = db.Questions.ToList();
            }
            myExcel.Export(MyTool.ConvertToDataTable(lst));
            MessageBox.Show("Xuất câu hỏi thành công!");
        }
コード例 #5
0
 private void içeriAktarToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         MyTool.JSon <MyContext>(ref Context, new OpenFileDialog());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #6
0
ファイル: BulletMain.cs プロジェクト: LJH960101/Prototype2
 void Start()
 {
     onDestroy          = false;
     realPos            = transform.position;
     initVelocity       = transform.GetComponent <Rigidbody>().velocity;
     initPos            = MyTool.GetPlayerGameObject(_bulletTargetPlayer).GetComponent <PlayerShooter>().shotPoint.position;
     transform.position = initPos;
     transform.GetComponent <Rigidbody>().velocity = Vector2.zero;
     targetPos   = realPos + initVelocity * lerpTime;
     onLerp      = true;
     lerpCounter = 0.0f;
 }
コード例 #7
0
    void InGameListner()
    {
        int counter = 0;

        print("Start");
        while (true)
        {
            byte[] buf = new byte[1024];
            try {
                udpClient.ReceiveFrom(buf, ref targetEndPoint);
                if (buf.Length > 0)
                {
                    // CNM에서 현재 아이디와 일치하는 정보를 빼온다. 누락됬다면 몽땅 처리해버림.
                    ClientNetworkMessage cnm = MyTool.BytesToStruct <ClientNetworkMessage>(buf);
                    while (counter != cnm.first_id + 1) // 마지막(첫번째) 데이터와 일치할때까지
                    {
                        byte[] currentBuf;
                        if (cnm.first_id == counter)
                        {
                            ++counter;
                            currentBuf = cnm.first;
                        }
                        else if (cnm.first_id + 1 == counter)
                        {
                            currentBuf = cnm.second;
                            ++counter;
                        }
                        else if (cnm.first_id + 2 == counter)
                        {
                            ++counter;
                            currentBuf = cnm.third;
                        }
                        else
                        {
                            counter    = cnm.first_id + 1;
                            currentBuf = cnm.third;
                        }
                        lock (listenerLocker)
                        {
                            networkReceivedList.Enqueue(currentBuf);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                print("리스너 폭팔 : " + e.Message);
                refreshThread = true;
                break;
            }
        }
        print("Exit");
    }
コード例 #8
0
ファイル: ToolTask_Tests.cs プロジェクト: hongli051/IronyTest
        public void EnvironmentVariablesToToolTaskNotSet()
        {
            MyTool task = new MyTool();

            task.BuildEngine          = new MockEngine();
            task.EnvironmentVariables = null;
            bool result = task.Execute();

            Assert.Equal(true, result);
            Assert.Equal(true, task.ExecuteCalled);
            Assert.Equal(true, task.StartInfo.EnvironmentVariables["username"].Length > 0);
        }
コード例 #9
0
ファイル: ToolTask_Tests.cs プロジェクト: hongli051/IronyTest
        public void ToolExeWinsOverToolName()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine  = engine;
                t.FullToolName = "c:\\baz\\foo.exe";

                Assert.Equal("foo.exe", t.ToolExe);
                t.ToolExe = "bar.exe";
                Assert.Equal("bar.exe", t.ToolExe);
            }
        }
コード例 #10
0
 void Die()
 {
     onDie = true;
     GetComponent <BoxCollider>().enabled = false;
     GetComponent <Monster>().enabled     = false;
     transform.Find("MonsterMove").gameObject.SetActive(false);
     transform.Find("MonsterAttack").gameObject.SetActive(false);
     transform.Find("HPFrame").gameObject.SetActive(false);
     _as.PlayOneShot(dieSound);
     Instantiate(effect1, transform.position, Quaternion.Euler(new Vector3(-90, 0f, 0f)));
     Instantiate(effect2, transform.position, Quaternion.Euler(new Vector3(-90, 0f, 0f)));
     MyTool.GetLocalPlayer().RemoveMonster(this);
 }
コード例 #11
0
        public async Task <IActionResult> Create([Bind("MaHh,TenHh,DonGia,SoLuong,Hinh,MoTa,MaLoai")] HangHoa hangHoa, IFormFile fHinh)
        {
            if (ModelState.IsValid)
            {
                hangHoa.Hinh = MyTool.UploadHinh(fHinh, "HangHoa");
                _context.Add(hangHoa);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaLoai"] = new SelectList(_context.Loais, "MaLoai", "MaLoai", hangHoa.MaLoai);
            return(View(hangHoa));
        }
コード例 #12
0
        public void VisualBasicLikeEscapedQuotesInCommandAreNotMadeForwardSlashes()
        {
            MyTool     t      = new MyTool();
            MockEngine engine = new MockEngine();

            t.BuildEngine             = engine;
            t.MockCommandLineCommands = NativeMethodsShared.IsWindows
                                            ? "/C echo \"hello \\\"world\\\"\""
                                            : "-c echo \"hello \\\"world\\\"\"";
            t.Execute();
            engine.AssertLogContains("echo \"hello \\\"world\\\"\"");
            Assert.Equal(0, engine.Errors);
        }
コード例 #13
0
        public void ToolExeWinsOverToolName()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine  = engine;
                t.FullToolName = NativeMethodsShared.IsWindows ? "c:\\baz\\foo.exe" : "/baz/foo.exe";

                Assert.Equal("foo.exe", t.ToolExe);
                t.ToolExe = "bar.exe";
                Assert.Equal("bar.exe", t.ToolExe);
            }
        }
コード例 #14
0
ファイル: ToolTask_Tests.cs プロジェクト: hongli051/IronyTest
        public void Regress_Mutation_MissingExecutableIsLogged()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;
                t.ToolPath    = @"C:\MyAlternatePath";

                Assert.False(t.Execute());

                // There should be an error about invalid task location.
                engine.AssertLogContains("MSB6004");
            }
        }
コード例 #15
0
        public void Regress_Mutation_MissingExecutableIsLogged()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;
                t.ToolPath    = NativeMethodsShared.IsWindows ? @"C:\MyAlternatePath" : "/MyAlternatePath";

                t.Execute().ShouldBeFalse();

                // There should be an error about invalid task location.
                engine.AssertLogContains("MSB6004");
            }
        }
コード例 #16
0
        public void DoNotFormatTaskCommandOrMessage()
        {
            MyTool     t      = new MyTool();
            MockEngine engine = new MockEngine();

            t.BuildEngine = engine;
            // Unmatched curly would crash if they did
            t.MockCommandLineCommands = NativeMethodsShared.IsWindows
                                            ? "/C echo hello world {"
                                            : @"-c """"""echo hello world {""""""";
            t.Execute();
            engine.AssertLogContains("echo hello world {");
            Assert.Equal(0, engine.Errors);
        }
コード例 #17
0
        private void içeriAktarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Context gelenData = new Context();

            try
            {
                MyTool.Json <Context>(ref gelenData, new OpenFileDialog());
                MyContext = gelenData;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #18
0
ファイル: ToolTask_Tests.cs プロジェクト: hongli051/IronyTest
        public void Regress_Mutation_UserSuppliedToolPathIsLogged()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;
                t.ToolPath    = @"C:\MyAlternatePath";

                t.Execute();

                // The alternate path should be mentioned in the log.
                engine.AssertLogContains("MyAlternatePath");
            }
        }
コード例 #19
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     dtOne         = dtOne.Add(-_1s);
     lblHours.Text = MyTool.AddZeroStr(dtOne.Hours, 2);
     lblMin.Text   = MyTool.AddZeroStr(dtOne.Minutes, 2);
     lblSec.Text   = MyTool.AddZeroStr(dtOne.Seconds, 2);
     if (openflag)//若开奖则进行返奖计算
     {
         openflag = false;
         //LotteryOpenDAL.BackWinMoney(lastOpen.Id);//返奖(考虑新进程?)
         idList.Add(lastOpen.Id);
         //var bList=LotteryOpenDAL.GetBetInfoById(idList);
         //var loList = LotteryOpenDAL.GetLotteryOpenById(idList);
         //var query = (from a in loList
         //             join b in bList on a.Id equals b.LotteryOpenId into t
         //             from tt in t.DefaultIfEmpty()
         //             group tt by new { a.Id, a.Expect, a.OpenNum, a.OpenTime } into g
         //             select new
         //             {
         //                 g.Key.Id,
         //                 g.Key.Expect,
         //                 g.Key.OpenNum,
         //                 g.Key.OpenTime,
         //                 TotalBackMoney =g.Sum(n =>n==null?0:n.TotalBackMoney),
         //                 TotalBetMoney = g.Sum(n => n == null ? 0 : n.TotalBetMoney),
         //                 WinMoney = g.Sum(n => n == null ? 0 : n.WinMoney)
         //             }).ToList();
         //var query = loList.Select(n => new
         //    {
         //        n.Id,n.Expect,n.OpenNum,n.OpenTime,
         //        TotalBackMoney=bList.Where(w=>w.LotteryOpenId==n.Id).Sum(w=>w.TotalBackMoney),
         //        TotalBetMoney = bList.Where(w => w.LotteryOpenId == n.Id).Sum(w => w.TotalBetMoney),
         //        WinMoney = bList.Where(w => w.LotteryOpenId == n.Id).Sum(w => w.WinMoney),
         //    }).ToList();
         //dgvInfo.DataSource = LotteryOpenDAL.GetBetInfoById(idList);
     }
     if (dtOne.TotalSeconds == 0)
     {
         // LotteryOpenDAL.OpeningNo(nextOpen.Id, cbFixed.Checked, txtNo1.Text.Trim(), txtNo2.Text.Trim(), txtNo3.Text.Trim(), txtNo4.Text.Trim(), txtNo5.Text.Trim());//开奖
         //重置计时器
         //nextOpen = LotteryOpenDAL.NextOpenNo();
         //if (nextOpen != null)
         //{
         //    lastOpen = LotteryOpenDAL.LastOpenNo(nextOpen.Id);
         //}
         showOpenInfo();
         openflag = true;
     }
 }
コード例 #20
0
        public async Task <IActionResult> Create(HangHoa hangHoa, IFormFile fHinh)
        {
            if (ModelState.IsValid)
            {
                hangHoa.Hinh = MyTool.UploadImage(fHinh);

                _context.Add(hangHoa);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaLoai"] = new SelectList(_context.Loai, "MaLoai", "TenLoai", hangHoa.MaLoai);
            ViewData["MaNcc"]  = new SelectList(_context.NhaCungCap, "MaNcc", "TenCongTy", hangHoa.MaNcc);
            return(View(hangHoa));
        }
コード例 #21
0
ファイル: ToolTask_Tests.cs プロジェクト: hongli051/IronyTest
        public void TaskFoundOnPath()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine  = engine;
                t.FullToolName = "cmd.exe";

                Assert.True(t.Execute());
                Assert.Equal(0, t.ExitCode);
                Assert.Equal(0, engine.Errors);

                engine.AssertLogContains(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "cmd.exe"));
            }
        }
コード例 #22
0
    public void SendAttack(CharacterType type, int damage)
    {
        CM_AttackSuccess myMsg = new CM_AttackSuccess();

        myMsg.type   = type;
        myMsg.damage = damage;
        byte[] newMsg = MyTool.StructToBytes <CM_AttackSuccess>(myMsg);
        byte[] newBuf = new byte[newMsg.Length + 1];
        newBuf[0] = (byte)CTCType.AttackSuccess;
        for (int i = 0; i < newMsg.Length; ++i)
        {
            newBuf[i + 1] = newMsg[i];
        }
        networkSendList.Add(newBuf);
    }
コード例 #23
0
    public void SendDeath(CharacterType type, Vector3 position)
    {
        CM_NoticeDeath myMsg = new CM_NoticeDeath();

        myMsg.characterType = type;
        myMsg.position      = position;
        byte[] newMsg = MyTool.StructToBytes <CM_NoticeDeath>(myMsg);
        byte[] newBuf = new byte[newMsg.Length + 1];
        newBuf[0] = (byte)CTCType.NoticeDeath;
        for (int i = 0; i < newMsg.Length; ++i)
        {
            newBuf[i + 1] = newMsg[i];
        }
        networkSendList.Add(newBuf);
    }
コード例 #24
0
    public void SendPosition(Vector3 position, Vector3 velocity)
    {
        CM_UpdatePosition myMsg = new CM_UpdatePosition();

        myMsg.position = position;
        myMsg.velocity = velocity;
        byte[] newMsg = MyTool.StructToBytes <CM_UpdatePosition>(myMsg);
        byte[] newBuf = new byte[newMsg.Length + 1];
        newBuf[0] = (byte)CTCType.UpdatePosition;
        for (int i = 0; i < newMsg.Length; ++i)
        {
            newBuf[i + 1] = newMsg[i];
        }
        networkSendList.Add(newBuf);
    }
コード例 #25
0
 public void GetDamage(int damage, int bulletShooterCode)
 {
     _hp -= damage;
     if (_hp <= 0 && isServer)
     {
         MyTool.GetPlayerGameObject(bulletShooterCode).GetComponent <PlayerNetwork>().CmdAddScore(bulletShooterCode % 2 == 1, 8);
         Destroy(gameObject, 3.0f);
         RpcDie();
         Die();
     }
     else
     {
         RefreshHp();
     }
 }
コード例 #26
0
ファイル: ToolTask_Tests.cs プロジェクト: hongli051/IronyTest
        public void TaskNotFoundOnPath()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine  = engine;
                t.FullToolName = "doesnotexist.exe";

                Assert.False(t.Execute());
                Assert.Equal(-1, t.ExitCode);
                Assert.Equal(1, engine.Errors);

                // Does not throw an exception
            }
        }
コード例 #27
0
        public void EnvironmentVariablesToToolTaskEqualsSign()
        {
            MyTool task = new MyTool();

            task.BuildEngine          = new MockEngine();
            task.EnvironmentVariables = new string[] { "a=b=c" };
            bool result = task.Execute();

            Assert.Equal(true, result);
#if FEATURE_PROCESSSTARTINFO_ENVIRONMENT
            Assert.Equal("b=c", task.StartInfo.Environment["a"]);
#else
            Assert.Equal("b=c", task.StartInfo.EnvironmentVariables["a"]);
#endif
        }
コード例 #28
0
        public void TaskNotFoundOnPath()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine  = engine;
                t.FullToolName = "doesnotexist.exe";

                t.Execute().ShouldBeFalse();
                t.ExitCode.ShouldBe(-1);
                engine.Errors.ShouldBe(1);

                // Does not throw an exception
            }
        }
コード例 #29
0
    void BuyItem(int stuffCode)
    {
        Stuff stuff = MyTool.GetStuff(stuffCode);

        if (stuff == null)
        {
            Debug.LogError("Not exist stuffCode");
        }
        if (stuff.bOnCoolTime())
        {
            return;
        }
        if (!_pm.attackAble && stuff.stuffType == Stuff.StuffType.BOMB)
        {
            return;
        }
        if (stuff.GetPrice() < _pm.Money)
        {
            _pm.CmdAddMoney(-stuff.GetPrice());
            _pm.Money -= stuff.GetPrice();
            bool successToUse = stuff.Use();
            if (successToUse)
            {
                switch (stuff.stuffType)
                {
                case Stuff.StuffType.ATTACK_SPEED:
                    CmdAddAttackSpeed();
                    break;

                case Stuff.StuffType.BOMB:
                    CmdSpawnBomb();
                    break;

                case Stuff.StuffType.HP:
                    _pm.CmdAddMaxHp();
                    break;

                case Stuff.StuffType.POWER:
                    CmdAddDamage();
                    break;

                case Stuff.StuffType.SPEED:
                    CmdAddSpeed();
                    break;
                }
            }
        }
    }
コード例 #30
0
ファイル: ToolTask_Tests.cs プロジェクト: hongli051/IronyTest
        public void DoNotErrorWhenTextSentToStandardError()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine             = engine;
                t.MockCommandLineCommands = "/C Echo 'Who made you king anyways' 1>&2";

                Assert.True(t.Execute());

                engine.AssertLogDoesntContain("MSB");
                engine.AssertLogContains("Who made you king anyways");
                Assert.Equal(0, t.ExitCode);
                Assert.Equal(0, engine.Errors);
            }
        }
コード例 #31
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void ErrorWhenTextSentToStandardError()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;
                t.LogStandardErrorAsError = true;
                t.MockCommandLineCommands = "/C Echo 'Who made you king anyways' 1>&2";

                Assert.IsFalse(t.Execute());

                engine.AssertLogDoesntContain("MSB3073");
                engine.AssertLogContains("Who made you king anyways");
                Assert.AreEqual(-1, t.ExitCode);
                Assert.AreEqual(1, engine.Errors);
            }
        }
コード例 #32
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void Regress_Mutation_WarnIfCommandLineTooLong()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;

                // "cmd.exe" croaks big-time when given a very long command-line.  It pops up a message box on
                // Windows XP.  We can't have that!  So use "attrib.exe" for this exercise instead.
                t.FullToolName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "attrib.exe");

                t.MockCommandLineCommands = new String('x', 32001);

                // It's only a warning, we still succeed
                Assert.IsTrue(t.Execute());
                Assert.AreEqual(0, t.ExitCode);
                // There should be a warning about the command-line being too long.
                engine.AssertLogContains("MSB6002");
            }
        }
コード例 #33
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void Regress_Mutation_MissingExecutableIsLogged()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;
                t.ToolPath = @"C:\MyAlternatePath";

                Assert.IsFalse(t.Execute());

                // There should be an error about invalid task location.
                engine.AssertLogContains("MSB6004");
            }
        }
コード例 #34
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void HandleExecutionErrorsWhenToolLogsError()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;
                t.MockCommandLineCommands = "/C echo Main.cs(17,20): error CS0168: The variable 'foo' is declared but never used";

                Assert.IsFalse(t.Execute());

                // The above command logged a canonical error message.  Therefore ToolTask should
                // not log its own error beyond that.
                engine.AssertLogDoesntContain("MSB6006");
                engine.AssertLogContains("CS0168");
                engine.AssertLogContains("The variable 'foo' is declared but never used");
                Assert.AreEqual(-1, t.ExitCode);
                Assert.AreEqual(1, engine.Errors);
            }
        }
コード例 #35
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void HandleExecutionErrorsWhenToolDoesntLogError()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;
                t.MockCommandLineCommands = "/C garbagegarbagegarbagegarbage.exe";

                Assert.IsFalse(t.Execute());
                Assert.AreEqual(1, t.ExitCode); // cmd.exe error code is 1

                // We just tried to run "cmd.exe /C garbagegarbagegarbagegarbage.exe".  This should fail,
                // but since "cmd.exe" doesn't log its errors in canonical format, no errors got
                // logged by the tool itself.  Therefore, ToolTask's default implementation of 
                // HandleTaskExecutionErrors should have logged error MSB6006.
                engine.AssertLogContains("MSB6006");
            }
        }
コード例 #36
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
 public void DoNotFormatTaskCommandOrMessage()
 {
     MyTool t = new MyTool();
     MockEngine engine = new MockEngine();
     t.BuildEngine = engine;
     t.MockCommandLineCommands = "/C echo hello world {"; // Unmatched curly would crash if they did
     t.Execute();
     engine.AssertLogContains("echo hello world {");
     Assert.AreEqual(0, engine.Errors);
 }
コード例 #37
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void ToolTaskCanChangeCanonicalErrorFormat()
        {
            string tempFile = FileUtilities.GetTemporaryFile();
            File.WriteAllText(tempFile, @"
                Main.cs(17,20): warning CS0168: The variable 'foo' is declared but never used.
                BADTHINGHAPPENED: This is my custom error format that's not in canonical error format.
                ");

            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;
                // The command we're giving is the command to spew the contents of the temp
                // file we created above.
                t.MockCommandLineCommands = "/C type \"" + tempFile + "\"";

                t.Execute();

                // The above command logged a canonical warning, as well as a custom error.
                engine.AssertLogContains("CS0168");
                engine.AssertLogContains("The variable 'foo' is declared but never used");
                engine.AssertLogContains("BADTHINGHAPPENED");
                engine.AssertLogContains("This is my custom error format");

                Assert.AreEqual(1, engine.Warnings, "Expected one warning in log.");
                Assert.AreEqual(1, engine.Errors, "Expected one error in log.");
            }

            File.Delete(tempFile);
        }
コード例 #38
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void Regress_Mutation_UserSuppliedToolPathIsLogged()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;
                t.ToolPath = @"C:\MyAlternatePath";

                t.Execute();

                // The alternate path should be mentioned in the log.
                engine.AssertLogContains("MyAlternatePath");
            }
        }
コード例 #39
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void OverrideStdOutImportanceToHigh()
        {
            string tempFile = FileUtilities.GetTemporaryFile();
            File.WriteAllText(tempFile, @"hello world");

            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                engine.MinimumMessageImportance = MessageImportance.High;

                t.BuildEngine = engine;
                t.FullToolName = "find.exe";
                t.MockCommandLineCommands = "\"hello\" \"" + tempFile + "\"";
                t.StandardOutputImportance = "High";

                Assert.IsTrue(t.Execute());
                Assert.AreEqual(0, t.ExitCode);
                Assert.AreEqual(0, engine.Errors);

                engine.AssertLogContains("hello world");
            }
            File.Delete(tempFile);
        }
コード例 #40
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void TaskNotFoundOnPath()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;
                t.FullToolName = "doesnotexist.exe";

                Assert.IsFalse(t.Execute());
                Assert.AreEqual(-1, t.ExitCode);
                Assert.AreEqual(1, engine.Errors);

                // Does not throw an exception
            }
        }
コード例 #41
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void EnvironmentVariablesToToolTask()
        {
            MyTool task = new MyTool();
            task.BuildEngine = new MockEngine();
            task.EnvironmentVariables = new string[] { "a=b", "c=d", "username=x" /* built-in */, "path=" /* blank value */};
            bool result = task.Execute();

            Assert.AreEqual(true, result);
            Assert.AreEqual(true, task.ExecuteCalled);

            ProcessStartInfo startInfo = task.StartInfo;

            Assert.AreEqual("b", startInfo.EnvironmentVariables["a"]);
            Assert.AreEqual("d", startInfo.EnvironmentVariables["c"]);
            Assert.AreEqual("x", startInfo.EnvironmentVariables["username"]);
            Assert.AreEqual(String.Empty, startInfo.EnvironmentVariables["path"]);
            Assert.IsTrue(String.Equals(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), startInfo.EnvironmentVariables["programfiles"], StringComparison.OrdinalIgnoreCase));
        }
コード例 #42
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void EnvironmentVariablesToToolTaskNotSet()
        {
            MyTool task = new MyTool();
            task.BuildEngine = new MockEngine();
            task.EnvironmentVariables = null;
            bool result = task.Execute();

            Assert.AreEqual(true, result);
            Assert.AreEqual(true, task.ExecuteCalled);
            Assert.AreEqual(true, task.StartInfo.EnvironmentVariables["username"].Length > 0);
        }
コード例 #43
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void EnvironmentVariablesToToolTaskInvalid3()
        {
            MyTool task = new MyTool();
            task.BuildEngine = new MockEngine();
            task.EnvironmentVariables = new string[] { "=a;b=c" };
            bool result = task.Execute();

            Assert.AreEqual(false, result);
            Assert.AreEqual(false, task.ExecuteCalled);
        }
コード例 #44
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void EnvironmentVariablesToToolTaskEqualsSign()
        {
            MyTool task = new MyTool();
            task.BuildEngine = new MockEngine();
            task.EnvironmentVariables = new string[] { "a=b=c" };
            bool result = task.Execute();

            Assert.AreEqual(true, result);
            Assert.AreEqual("b=c", task.StartInfo.EnvironmentVariables["a"]);
        }
コード例 #45
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void ToolExeWinsOverToolName()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;
                t.FullToolName = "c:\\baz\\foo.exe";

                Assert.AreEqual("foo.exe", t.ToolExe);
                t.ToolExe = "bar.exe";
                Assert.AreEqual("bar.exe", t.ToolExe);
            }
        }
コード例 #46
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void TaskFoundOnPath()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;
                t.FullToolName = "cmd.exe";

                Assert.IsTrue(t.Execute());
                Assert.AreEqual(0, t.ExitCode);
                Assert.AreEqual(0, engine.Errors);

                engine.AssertLogContains(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "cmd.exe"));
            }
        }
コード例 #47
0
ファイル: ToolTask_Tests.cs プロジェクト: JamesLinus/msbuild
        public void ToolExeIsFoundOnToolPath()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;
                t.FullToolName = "cmd.exe";
                string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
                t.ToolPath = systemPath;

                t.Execute();
                Assert.AreEqual(Path.Combine(systemPath, "cmd.exe"), t.PathToToolUsed);
                engine.AssertLogContains("cmd.exe");
                engine.Log = String.Empty;

                t.ToolExe = "xcopy.exe";
                t.Execute();
                Assert.AreEqual(Path.Combine(systemPath, "xcopy.exe"), t.PathToToolUsed);
                engine.AssertLogContains("xcopy.exe");
                engine.AssertLogDoesntContain("cmd.exe");
            }
        }
コード例 #48
0
ファイル: ToolTask_Tests.cs プロジェクト: cameron314/msbuild
        public void DoNotErrorWhenTextSentToStandardOutput()
        {
            using (MyTool t = new MyTool())
            {
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;
                t.LogStandardErrorAsError = true;
                t.MockCommandLineCommands = "/C Echo 'Who made you king anyways'";

                Assert.True(t.Execute());

                engine.AssertLogDoesntContain("MSB");
                engine.AssertLogContains("Who made you king anyways");
                Assert.Equal(0, t.ExitCode);
                Assert.Equal(0, engine.Errors);
            }
        }