コード例 #1
0
        public void DeleteRecord_DeleteExisting_IgnoreNonExisting(User user, int selectedDay, int selectedMonth, int selectedStart, int selectedEnd,
                                                                  bool exist)
        {
            var size   = RecordModel.GetAllRecords().Count;
            var record = new Record(user, selectedDay, selectedMonth, selectedStart, selectedEnd);

            //Record is exist or not
            if (exist)
            {
                //Add record
                RecordModel.CreateRecord(user, selectedDay, selectedMonth, selectedStart, selectedEnd, true);
                Assert.AreEqual(size + 1, RecordModel.GetAllRecords().Count);

                //Select record from Record List
                var selectedRecord =
                    RecordModel.FindRecordByUserInputString(record.FromTime.ToString("dd MMMM, HH:mm") + "—" +
                                                            record.ToTime.Hour + ":00");

                //Delete selected record
                RecordModel.DeleteRecord(selectedRecord, user.Id);
                Assert.AreEqual(size, RecordModel.GetAllRecords().Count);
            }
            else
            {
                //Select record from Record List
                var selectedRecord =
                    RecordModel.FindRecordByUserInputString(record.FromTime.ToString("dd MMMM, HH:mm") + "—" +
                                                            record.ToTime.Hour + ":00");
                //Delete non-exist record
                RecordModel.DeleteRecord(selectedRecord, user.Id);
                Assert.AreEqual(size, RecordModel.GetAllRecords().Count);
            }
        }
コード例 #2
0
        public void FindRecordByUserInputString_FromTheModel(User user, int selectedDay, int selectedMonth, int selectedStart, int selectedEnd,
                                                             bool exist)
        {
            var size       = RecordModel.GetAllRecords().Count;
            var testRecord = new Record(user, selectedDay, selectedMonth, selectedStart, selectedEnd);
            var text       = testRecord.FromTime.ToString("dd MMMM, HH:mm") + "—" + testRecord.ToTime.Hour + ":00";

            //Record is exist or not
            if (exist)
            {
                //Add record
                RecordModel.CreateRecord(user, selectedDay, selectedMonth, selectedStart, selectedEnd, exist);
                Assert.AreEqual(size + 1, RecordModel.GetAllRecords().Count);

                //Select record from Record List
                var record = RecordModel.FindRecordByUserInputString(text);
                Assert.NotNull(record);
                StringAssert.AreEqualIgnoringCase(text,
                                                  record.FromTime.ToString("dd MMMM, HH:mm") + "—" + record.ToTime.Hour + ":00");
            }
            else
            {
                var record = RecordModel.FindRecordByUserInputString(text);
                Assert.Null(record);
            }
        }
コード例 #3
0
        public void CreateRecord_AddValidRecords(int count, int month, bool secondRound)
        {
            var user    = new User();
            var size    = RecordModel.GetAllRecords().Count;
            var counter = 0;

            while (counter < count)
            {
                for (var day = 1; day <= 28; day++)
                {
                    if (counter == count)
                    {
                        break;
                    }
                    for (var i = 8; i < 21; i++)
                    {
                        if (counter == count)
                        {
                            break;
                        }
                        if (!secondRound)
                        {
                            RecordModel.CreateRecord(user, day, month, i, i + 1, true);
                        }
                        //todo bug found here
                        else
                        {
                            CreateRecord_AddValidRecord_RefuseInvalidRecord(new DateTime(DateTime.Now.Year, month, day, i, 0, 0), i + 1, true, false);
                        }
                        counter++;
                    }
                }

                month++;
            }

            Assert.AreEqual(size + counter, RecordModel.GetAllRecords().Count);
            if (!secondRound)
            {
                CreateRecord_AddValidRecords(count, month, true);
            }
        }
コード例 #4
0
 public bool Create(Telegram.Bot.Types.User user)
 {
     return(RecordModel.CreateRecord(user, SelectedDay, SelectedMonth, SelectedStart, SelectedEnd, true));
 }