Пример #1
0
    public static void GetTotalCallsCost_TwoCallsAdded_ReturnsCallsCost()
    {
        var sut = new Analyzer(_dummyLargeThreshold, _dummyLargeThreshold);

        var expense = new Expense(10.00m, ExpenseType.CellPhoneCall, new DateTime());

        sut.Add(expense);
        sut.Add(expense);
        var currentCost = sut.GetTotalCallsCost();

        Assert.AreEqual(20.00m, currentCost);
    }
Пример #2
0
    public static void GetTotalCallsCost_LandlineCallsExceedLandlineCallsThreshold_SumReturnsLandLineCallsThreshold()
    {
        var sut = new Analyzer(29.00m, 10.00m);

        var landLineExpense = new Expense(5.0m, ExpenseType.LandlineCall, new DateTime());

        sut.Add(landLineExpense);
        sut.Add(landLineExpense);
        sut.Add(landLineExpense);
        var currentCost = sut.GetTotalCallsCost();

        Assert.AreEqual(10.00m, currentCost);
    }
Пример #3
0
    public static void GetTotalCallsCost_CallsExceedCostThreshold_ReturnsCallsCostNoGreaterThanThreshold()
    {
        var sut = new Analyzer(29.00m, _dummyLargeThreshold);

        var expense = new Expense(10.00m, ExpenseType.CellPhoneCall, new DateTime());

        sut.Add(expense);
        sut.Add(expense);
        sut.Add(expense);
        var currentCost = sut.GetTotalCallsCost();

        Assert.AreEqual(29.00m, currentCost);
    }
Пример #4
0
    public static void GetTotalCallsCost_AddingLanlineCall_AddsChargeToCost()
    {
        var sut = new Analyzer(29.00m, _dummyLargeThreshold);

        var callPhoneCall   = new Expense(10.00m, ExpenseType.CellPhoneCall, new DateTime());
        var landLineExpense = new Expense(5.0m, ExpenseType.LandlineCall, new DateTime());

        sut.Add(callPhoneCall);
        sut.Add(callPhoneCall);
        sut.Add(landLineExpense);
        var currentCost = sut.GetTotalCallsCost();

        Assert.AreEqual(25.00m, currentCost);
    }
Пример #5
0
    public static void GetTotalCallsCost_AddingInternationlCallAndThresholdsAreReached_SpecialSmsCostIsAddedToTotalCost()
    {
        var sut = new Analyzer(29.00m, 10.00m);

        var cellPhoneExponse  = new Expense(30.0m, ExpenseType.CellPhoneCall, new DateTime());
        var landLineExpense   = new Expense(30.0m, ExpenseType.LandlineCall, new DateTime());
        var internationalCall = new Expense(2.49m, ExpenseType.InternationalCall, new DateTime());

        sut.Add(cellPhoneExponse);
        sut.Add(landLineExpense);
        sut.Add(internationalCall);
        var currentCost = sut.GetTotalCallsCost();

        Assert.AreEqual(41.49m, currentCost);
    }
Пример #6
0
    public static void GetTotalCallsCost_AddingMobileDataCostAndCellPhoneCallsCostIsReached_SumReturnsCellPhoneThreshold()
    {
        var sut = new Analyzer(29.00m, 10.00m);

        var cellPhoneExponse = new Expense(10.0m, ExpenseType.CellPhoneCall, new DateTime());
        var mobileData       = new Expense(15.00m, ExpenseType.MobileData, new DateTime());

        sut.Add(cellPhoneExponse);
        sut.Add(cellPhoneExponse);
        sut.Add(cellPhoneExponse);
        sut.Add(mobileData);
        var currentCost = sut.GetTotalCallsCost();

        Assert.AreEqual(29.00m, currentCost);
    }
Пример #7
0
        private void buttonLoadChannels_Click(object sender, EventArgs e)
        {
            foreach (LogFileMonitor monitor in listFiles.CheckedItems)
            {
                logReaderUI.Add(monitor);
                listLoadedChannels.Items.Add(monitor);

                Analyzer.Add(monitor);
            }
        }
Пример #8
0
    public static void GetTotalCallsCost_AddingMmsExpense_AddsMmsExpenseToMobileExpenses()
    {
        var sut = new Analyzer(29.00m, 10.00m);

        var cellPhoneExponse = new Expense(0.19m, ExpenseType.MMS, new DateTime());

        sut.Add(cellPhoneExponse);
        var costDetails = sut.GetCostDetails();

        Assert.AreEqual(0.19m, costDetails.CellPhoneCallsTotalCost);
    }
Пример #9
0
    public void analysing_expenses_for_may_returns_expected_total_cost()
    {
        Environment.CurrentDirectory = TestContext.CurrentContext.TestDirectory;
        var lines1    = File.ReadAllLines("./AcceptanceTest1/2018.05.19_2018.06.18.csv");
        var lines2    = File.ReadAllLines("./AcceptanceTest1/2018.05.19_2018.06.18_2.csv");
        var expenses1 = CsvToExpenseList.Parse(lines1);
        var expenses2 = CsvToExpenseList.Parse(lines2);
        var analyzer  = new Analyzer(29, 10);

        foreach (var expense in expenses1)
        {
            analyzer.Add(expense);
        }
        foreach (var expense in expenses2)
        {
            analyzer.Add(expense);
        }
        // 9zł is the extra change for my second number
        Assert.AreEqual(71.67m, analyzer.GetTotalCallsCost() + 9);
    }
Пример #10
0
        private bool LoadLogFileMonitor(LogFileMonitor monitor)
        {
            if (!listLoadedChannels.Items.Contains(monitor))
            {
                logReaderUI.Add(monitor);
                listLoadedChannels.Items.Add(monitor);
                Analyzer.Add(monitor);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #11
0
    public void CsvToExpenseList_and_Analyzer_work_together()
    {
        var lines = new string[]
        {
            "data i godzina;nr telefonu;liczba;zdarzenie;operator;koszt",
            "2018.06.15 21:24;4542259472;2:15min:sek; Rozmowa głosowa;Dania kom;0.57 zł"
        };
        var result   = CsvToExpenseList.Parse(lines);
        var analyzer = new Analyzer(10, 29);

        foreach (var expense in result)
        {
            analyzer.Add(expense);
        }
        Assert.AreEqual(0.57m, analyzer.GetTotalCallsCost());
    }
Пример #12
0
        public override int Execute(string command, object[] args, Dictionary <string, string> baseSettings, Dictionary <string, string> commandSettings)
        {
            if (!File.Exists($"{baseSettings["aion"]}{Path.DirectorySeparatorChar}Chat.log"))
            {
                return(4);
            }

            int code = 0;

            if (args.Length == 1)
            {
                if ((String)args[0] == "list")
                {
                    ConsoleOut("======== POINTER LIST ========");
                    foreach (KeyValuePair <string, string> item in Analyzer)
                    {
                        ConsoleOut(item.Key);
                    }
                    ConsoleOut("");
                }
                else
                {
                    code = 1;
                }
            }
            else if (args.Length >= 2)
            {
                switch (args[0])
                {
                case "add":
                    if (args.Length == 2)
                    {
                        if (!Analyzer.ContainsKey((String)args[1]))
                        {
                            Obj($"nda{args[1].ToString()}", "NerdyDamageAnalyzer.NerdyDamageAnalyzer", new object[] { $"{baseSettings["aion"]}{Path.DirectorySeparatorChar}Chat.log", baseSettings["language"], baseSettings["player"] }, this.CPatch("lib", "NerdyDamageanAlyzer.dll"));
                            Analyzer.Add(args[1].ToString(), $"nda{args[1].ToString()}");
                            IsInterval.Add(args[1].ToString(), false);
                        }
                        else
                        {
                            code = 2;
                        }
                    }
                    else if (args.Length == 3)
                    {
                        if (((String)args[1]) == "-i")
                        {
                            if (!Analyzer.ContainsKey((String)args[2]))
                            {
                                Obj($"nda{args[2].ToString()}", "NerdyDamageAnalyzer.NerdyDamageAnalyzer", new object[] { $"{baseSettings["aion"]}{Path.DirectorySeparatorChar}Chat.log", baseSettings["language"], baseSettings["player"] }, this.CPatch("lib", "NerdyDamageanAlyzer.dll"));
                                Analyzer.Add(args[2].ToString(), $"nda{args[2].ToString()}");
                                IsInterval.Add(args[2].ToString(), true);

                                ExMethod(Analyzer[(String)args[2]], "InitTimer", new object[] { }, new Type[] { });
                            }
                            else
                            {
                                code = 2;
                            }
                        }
                        else
                        {
                            code = 1;
                        }
                    }
                    else
                    {
                        code = 1;
                    }
                    break;

                case "clear":
                    if (args.Length == 2)
                    {
                        if (!Analyzer.ContainsKey((String)args[1]))
                        {
                            ExMethod(Analyzer[(String)args[1]], "Clear", new object[] { }, new Type[] { });
                        }
                        else
                        {
                            code = 3;
                        }
                    }
                    else
                    {
                        code = 1;
                    }
                    break;

                case "remove":
                    if (args.Length == 2)
                    {
                        if (!Analyzer.ContainsKey((String)args[1]))
                        {
                            RemoveObj(Analyzer[(String)args[1]]);
                            Analyzer.Remove((String)args[1]);
                            IsInterval.Remove((String)args[1]);
                        }
                        else
                        {
                            code = 3;
                        }
                    }
                    else
                    {
                        code = 1;
                    }
                    break;

                case "show":
                    if (args.Length == 2)
                    {
                        if (Analyzer.ContainsKey((String)args[1]))
                        {
                            if (!IsInterval[(String)args[1]])
                            {
                                ExMethod(Analyzer[(String)args[1]], "AnalyzeLog", new object[] { }, new Type[] { });
                            }

                            ConsoleOut("==== PLAYER LIST ====");

                            List <String> temp = new List <String>();
                            temp = (List <String>)ExMethod(Analyzer[(String)args[1]], "Show", new object[] { baseSettings["dmg_template"], baseSettings["sort_by"], Convert.ToInt32(baseSettings["show_max"]) }, new Type[] { typeof(String), typeof(String), typeof(int) });
                            for (int i = 0; i < temp.Count; i++)
                            {
                                ConsoleOut(temp[i]);
                            }

                            ConsoleOut("=====================");
                            ConsoleOut("");
                        }
                    }
                    else
                    {
                        code = 1;
                    }
                    break;

                case "copy":
                    if (args.Length == 2)
                    {
                        if (Analyzer.ContainsKey((String)args[1]))
                        {
                            if (!IsInterval[(String)args[1]])
                            {
                                ExMethod(Analyzer[(String)args[1]], "AnalyzeLog", new object[] { }, new Type[] { });
                            }

                            List <String> temp = new List <String>();
                            temp = (List <String>)ExMethod(Analyzer[(String)args[1]], "Show", new object[] { baseSettings["dmg_template"], baseSettings["sort_by"], Convert.ToInt32(baseSettings["show_max"]) }, new Type[] { typeof(String), typeof(String), typeof(int) });
                            String dmgData = "| ";
                            for (int i = 0; i < temp.Count; i++)
                            {
                                dmgData += temp[i] + " | ";
                            }

                            Thread thread = new Thread(() => Clipboard.SetText(dmgData));
                            thread.SetApartmentState(ApartmentState.STA);
                            thread.Start();
                            thread.Join();
                        }
                    }
                    else
                    {
                        code = 1;
                    }
                    break;

                default:
                    code = 1;
                    break;
                }
            }

            return(code);
        }