public void TestPut()
        {
            Record testRec = new Record {
                Artist = "Michael", Title = "svin", Duration = 222, YearOfPublication = "1987"
            };

            _recordController.Put(1, testRec);

            Assert.AreEqual("Michael", _recordController.Get(1).Artist);
        }
Пример #2
0
        public void testPut()
        {
            Record oldRecord = con.Get("Wow");

            oldRecord.Artist = "From";
            con.Put("Wow", oldRecord);
            Record updatedRecord = con.Get("Wow");

            Assert.AreEqual("From", updatedRecord.Artist);
        }
        public async void PutReturnsBadRequestWhenNoRecordProvided()
        {
            var mockRecordRepository = new Mock <IRecordRepository>();
            var recordRepository     = mockRecordRepository.Object;
            var target = new RecordsController(recordRepository);

            var result = await target.Put("ABC", null);

            Assert.IsAssignableFrom <BadRequestObjectResult>(result);
            Assert.Equal("No record supplied.", ((BadRequestObjectResult)result).Value);
        }
        public async void PutReturnsBadRequestWhenRecordHasNoId()
        {
            var mockRecordRepository = new Mock <IRecordRepository>();
            var recordRepository     = mockRecordRepository.Object;
            var target = new RecordsController(recordRepository);

            var result = await target.Put("ABC", new Models.Record {
                Id = "   ", Value = "This record has no Id."
            });

            Assert.IsAssignableFrom <BadRequestObjectResult>(result);
            Assert.Equal("Invalid record Id.", ((BadRequestObjectResult)result).Value);
        }
        public async void PutReturnsBadRequestWhenNoIdProvided()
        {
            var mockRecordRepository = new Mock <IRecordRepository>();
            var recordRepository     = mockRecordRepository.Object;
            var target = new RecordsController(recordRepository);

            var result = await target.Put("  ", new Models.Record {
                Id = "ABC", Value = "This is a good record."
            });

            Assert.IsAssignableFrom <BadRequestObjectResult>(result);
            Assert.Equal("Record Id not supplied.", ((BadRequestObjectResult)result).Value);
        }
        public async void PutUpdatesRecord()
        {
            var mockRecordRepository = new Mock <IRecordRepository>();
            var recordRepository     = mockRecordRepository.Object;
            var target = new RecordsController(recordRepository);

            var result = await target.Put("ABC", new Models.Record {
                Id = "ABC", Value = "This is an updated record."
            });

            Assert.IsAssignableFrom <HttpOkResult>(result);

            mockRecordRepository.Verify(
                p => p.Update("ABC", It.Is <Models.Record>(q => q.Id == "ABC" && q.Value == "This is an updated record.")),
                Times.Once);
        }
 public void TestPut()
 {
     recordsController.Put(4, new Record("Test", "test", new TimeSpan(00, 01, 01), new DateTime(1111, 01, 01), 4));
     Assert.AreEqual("Test", recordsController.Get(4).Title);
 }