public void ReturnNull_WhenIdParameterIsNull()
        {
            // Arrange
            var         contextMock = new Mock <IOnLineShopDbContext>();
            SizeService sizeService = new SizeService(contextMock.Object);

            // Act
            Size sizeResult = sizeService.GetById(null);

            // Assert
            Assert.IsNull(sizeResult);
        }
        public void ReturnNull_WhenIdParameterIsNull()
        {
            // Arrange

            var         wrapperMock   = new Mock <IEfDbSetWrapper <Size> >();
            var         dbContextMock = new Mock <IOnLineShopDbContextSaveChanges>();
            SizeService SizeService   = new SizeService(wrapperMock.Object, dbContextMock.Object);

            // Act
            Size SizeResult = SizeService.GetById(null);

            // Assert
            Assert.IsNull(SizeResult);
        }
Example #3
0
        // GET: /Category/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Size category = service.GetById(id);

            if (category == null)
            {
                return(HttpNotFound());
            }
            var result = AutoMapper.Mapper.Map <Size, BrandResponse>(category);

            return(View(category));
        }
        public void ReturnSize_WhenIdIsValid()
        {
            // Arrange
            var wrapperMock   = new Mock <IEfDbSetWrapper <Size> >();
            var dbContextMock = new Mock <IOnLineShopDbContextSaveChanges>();

            int  sizeId = 1;
            Size size   = new Size()
            {
                Id = sizeId, Value = "Size 1"
            };

            wrapperMock.Setup(m => m.GetById(sizeId)).Returns(size);

            SizeService sizeService = new SizeService(wrapperMock.Object, dbContextMock.Object);


            // Act
            Size SizeResult = sizeService.GetById(sizeId);

            // Assert
            Assert.AreSame(size, SizeResult);
        }
        public void ReturnSize_WhenIdIsValid()
        {
            // Arrange
            var contextMock = new Mock <IOnLineShopDbContext>();
            var sizeSetMock = new Mock <IDbSet <Size> >();

            contextMock.Setup(c => c.Sizes).Returns(sizeSetMock.Object);
            int  sizeId = 1;
            Size size   = new Size()
            {
                Id = sizeId, Value = "S"
            };

            sizeSetMock.Setup(b => b.Find(sizeId)).Returns(size);

            SizeService sizeService = new SizeService(contextMock.Object);

            // Act
            Size sizeResult = sizeService.GetById(sizeId);

            // Assert
            Assert.AreSame(size, sizeResult);
        }
Example #6
0
 public async Task <IActionResult> GetSizeById(Guid id)
 {
     return(Ok(await sizeService.GetById(id)));
 }