示例#1
0
        public void Delete_Throws()
        {
            // Arrange
            var mapper = Substitute.For <IMapper>();
            var repo   = Substitute.For <IRepository>();

            repo.DeleteRecord(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()).Returns(Task.FromException <int>(new System.Exception("Boom")));

            var logger = Substitute.For <ILogger <RecordsController> >();

            var target = new RecordsController(repo, logger, mapper);

            // Act
            var result = target.Delete("testAppName", "dataType", "version1").Result;

            // Assert
            logger.Received().Log(
                LogLevel.Error,
                Arg.Any <EventId>(),
                Arg.Is <object>(o => o.ToString() == "Boom"),
                null,
                Arg.Any <Func <object, Exception, string> >());

            Assert.IsType <BadRequestObjectResult>(result);
        }
        public void TestPostDelete()
        {
            Record testRec = new Record {
                Artist = "Lasse", Title = "røvturen", Duration = 217, YearOfPublication = "1987"
            };

            _recordController.Post(testRec);


            List <Record> recList = _recordController.Get().ToList();

            int recCount = recList.Count;

            Assert.AreEqual(recCount, _recordController.Get().Count());
            int highestId = 0;

            foreach (Record record in recList)
            {
                if (record.Id > highestId)
                {
                    highestId = record.Id;
                }
            }


            _recordController.Delete(highestId);

            Assert.AreEqual(recList.Count - 1, _recordController.Get().Count());
        }
示例#3
0
        public void testDelete()
        {
            con.Delete("Bla");


            Record getRecord = con.Get("Bla");

            Assert.AreEqual(records.Title, "Wow");
        }
        public async void DeleteReturnsBadRequestWhenNoIdProvided()
        {
            var mockRecordRepository = new Mock <IRecordRepository>();
            var recordRepository     = mockRecordRepository.Object;
            var target = new RecordsController(recordRepository);

            var result = await target.Delete("   ");

            Assert.IsAssignableFrom <BadRequestObjectResult>(result);
            Assert.Equal("Record Id not supplied.", ((BadRequestObjectResult)result).Value);
        }
示例#5
0
        public void TestGenderTrue()
        {
            var test = new RecordsController();

            test.Delete(); //Make sure there is nothing in the datasource.
            test.RawStringFormatter("Testing,Orlando,Male,Grey,05/01/1982");
            test.RawStringFormatter("Testing,Monica,Female,Turquoise,05/12/1989");
            test.RawStringFormatter("Testing,Orlando,Male,Grey,05/01/1982");
            ActionResult <String> actionResult = test.GetByGender();

            Assert.IsNotNull(actionResult);
        }
示例#6
0
        public void TestNameFalse()
        {
            var test = new RecordsController();

            test.Delete(); //Make sure there is nothing in the datasource.
            ActionResult <String> actionResult = test.GetByName();

            var status = (actionResult.Result as StatusCodeResult).StatusCode;

            int expectedStatus = 204;

            Assert.AreEqual(status, expectedStatus);
        }
        public async void DeleteDeletesRecord()
        {
            var mockRecordRepository = new Mock <IRecordRepository>();
            var recordRepository     = mockRecordRepository.Object;
            var target = new RecordsController(recordRepository);

            var result = await target.Delete("ABC");

            Assert.IsAssignableFrom <HttpOkResult>(result);

            mockRecordRepository.Verify(
                p => p.Delete("ABC"),
                Times.Once());
        }
示例#8
0
        public void Delete()
        {
            // Arrange
            var mapper = Substitute.For <IMapper>();
            var repo   = Substitute.For <IRepository>();

            repo.DeleteRecord(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()).Returns(Task.FromResult <int>(1));

            var logger = Substitute.For <ILogger <RecordsController> >();

            var target = new RecordsController(repo, logger, mapper);

            // Act
            var result = target.Delete("testAppName", "dataType", "version1").Result;

            // Assert
            Assert.IsType <OkResult>(result);
        }
示例#9
0
 //Отменить услугу
 private void CancelService()
 {
     try
     {
         var result = RecordsController.Delete(GridRecords[SelectedIndexRecord].RecordId);
         if (result)
         {
             MessageBox.Show("Услуга отменена!");
         }
         else
         {
             MessageBox.Show("Произошла ошибка! Услуга не отменена!");
         }
     }
     catch
     {
         MessageBox.Show("Выберите услугу!");
     }
 }
        public async Task Delete_WhenRecordIsNull_ShouldReturnBadRequestObjectResult()
        {
            var result = await _recordsController.Delete(null);

            result.Should().BeOfType <BadRequestObjectResult>();
        }
 public void TestDelete()
 {
     recordsController.Delete(4);
     Assert.IsNull(recordsController.Get(4));
 }