コード例 #1
0
        public void Edit_ErrorsWhenIdNotProvided()
        {
            var controller = new RatingsController();

            var response = controller.Details(null);

            response.Should().BeOfType <HttpStatusCodeResult>().Which.StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
        }
コード例 #2
0
        public void Details_ErrorsWhenIdNotFound()
        {
            var data    = new List <Rating>();
            var mockSet = Mock.CreateMockSet(data);

            mockSet.Setup(m => m.Find(It.IsAny <object[]>()))
            .Returns <object[]>(ids => data.FirstOrDefault(d => d.User_Rating_ID == (int)ids[0]));
            var mockdb = new Mock <PlayerMatcherEntitiesExtended>();

            mockdb.Setup(db => db.Ratings).Returns(mockSet.Object);
            var controller = new RatingsController(mockdb.Object);

            var response = controller.Details(1) as HttpStatusCodeResult;

            response.Should().BeOfType <HttpNotFoundResult>().Which.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
        }