Exemplo n.º 1
0
        /// <summary>
        ///     Deletes an record at the specified index list
        /// </summary>
        private static void Remove(string[] commands)
        {
            if (commands.Length < 2)
            {
                return;
            }

            if (!int.TryParse(commands[1], out var index))
            {
                index = -1;
            }

            if (index < 0 || index > CabinetService.GetRecordsCount() - 1)
            {
                return;
            }

            CabinetService.RemoveAt(index);

            Console.WriteLine("Record succesfully removed.");
        }
        public void TestGetRecordsCount()
        {
            //Arrange
            var       fileCabinet = new FileCabinetService();
            const int expected    = 2;

            //Act
            fileCabinet.Create("firstName", "lastName", "dateOfBirth");
            fileCabinet.Create("first", "last", "date");
            var result = fileCabinet.GetRecordsCount();

            //Assert
            Assert.AreEqual(expected, result);
        }