public void When_CreatedConvertedToCSV_GetCorrectString()
        {
            Created created = new Created {
                CreatedAt = "2000-01-01", Name = "Peter Parker", Numeral = "XIX"
            };
            string expectedCSV = @"""2000-01-01"",""Peter Parker"",""XIX""";
            string returnedCSV = created.GetCSV();

            Assert.Equal(expectedCSV, returnedCSV);
        }
Beispiel #2
0
        public IActionResult Post([FromBody] NameDateOfBirth nameDateOfBirth)
        {
            // ToDo
            // Validate input and return 400 if date invalid or name too short
            int yearsAge = age.Calculate(nameDateOfBirth.DateOfBirth);

            if (yearsAge < 1 || (nameDateOfBirth.Name?.Length ?? 0) < 6)
            {
                return(BadRequest());
            }

            string  romanAge = numerals.Convert(yearsAge);
            Created created  = new Created {
                Name      = nameDateOfBirth.Name,
                CreatedAt = DateTime.Now.ToString(),
                Numeral   = romanAge
            };

            fileHandler.WriteLine(created.GetCSV());
            return(Json(created));
        }