public async Task CreateUnitOfMeasure_Returns_CreatedAtRouteResult()
        {
            //Arrange
            _fixture.MockUnitOfMeasureRepository.Setup(x => x.CreateUnitOfMeasureAsync(It.IsAny <CreateUnitOfMeasureDto>()))
            .ReturnsAsync(_fixture.CreateUnitOfMeasureDtoResult);

            var controller = new UnitOfMeasureController(_fixture.MockUnitOfMeasureRepository.Object);

            //Act
            var result = await controller.CreateUnitOfMeasure(_fixture.ValidCreateUnitOfMeasureDto, _fixture.ApiVersion);

            //Assert
            var objectResult = result.Should().BeOfType <CreatedAtRouteResult>().Subject;

            objectResult.StatusCode.Should().Be(201);
            objectResult.RouteValues !["id"].Should().Be(3);
        public async Task GetUnitOfMeasures_Returns_OkObjectResult()
        {
            //Arrange
            _fixture.MockUnitOfMeasureRepository.Setup(x => x.GetUnitOfMeasuresAsync())
            .ReturnsAsync(_fixture.UnitOfMeasures);

            var controller = new UnitOfMeasureController(_fixture.MockUnitOfMeasureRepository.Object);

            //Act
            var result = await controller.GetUnitOfMeasures();

            //Assert
            var okResult = result.Should().BeOfType <OkObjectResult>().Subject;
            var uoms     = okResult.Value.Should().BeAssignableTo <IEnumerable <GetUnitOfMeasureDto> >().Subject;

            okResult.StatusCode.Should().Be(200);
            uoms.Should().HaveCount(2);
        }
        public async Task GetUnitOfMeasure_Returns_OkObjectResult()
        {
            //Arrange
            var id = 2;

            _fixture.MockUnitOfMeasureRepository.Setup(x => x.GetUnitOfMeasureAsync(It.IsAny <int>()))
            .ReturnsAsync(_fixture.UnitOfMeasures.Single(d => d.Id == id));

            var controller = new UnitOfMeasureController(_fixture.MockUnitOfMeasureRepository.Object);

            //Act
            var result = await controller.GetUnitOfMeasure(id);

            //Assert
            var okResult = result.Should().BeOfType <OkObjectResult>().Subject;
            var uom      = okResult.Value.Should().BeAssignableTo <GetUnitOfMeasureDto>().Subject;

            okResult.StatusCode.Should().Be(200);
            uom.Id.Should().Be(id);
            uom.Code.Should().Be("g");
            uom.Description.Should().Be("Gram");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            List <brandinfoinfo>     brLst  = new List <brandinfoinfo>();
            List <SupplierInfo>      supLst = new List <SupplierInfo>();
            List <Categoryinfo>      catLst = new List <Categoryinfo>();
            List <UnitOfMeasureInfo> umLst  = new List <UnitOfMeasureInfo>();
            BrandController          brcon  = new BrandController();
            SupplierController       supcon = new SupplierController();
            CategoryController       catcon = new CategoryController();
            UnitOfMeasureController  umcon  = new UnitOfMeasureController();

            if (!IsPostBack)
            {
                //brLst = brcon.SelectAllBrandInfo();
                //ddlBrand.DataSource = brLst;
                //ddlBrand.DataTextField = "BrandName";

                //ddlBrand.DataBind();
                ddlBrand.Items.Insert(0, new ListItem("-- Select Brand --", ""));

                supLst = supcon.SelectAllSupplierInfo();
                ddlSupplier.DataSource    = supLst;
                ddlSupplier.DataTextField = "SupplierName";
                ddlSupplier.DataBind();
                ddlSupplier.Items.Insert(0, new ListItem("-- Select Supplier --", ""));

                catLst = catcon.SelectAllCategoryInfo();
                ddlCateogry.DataSource    = catLst;
                ddlCateogry.DataTextField = "Type";
                ddlCateogry.DataBind();
                ddlCateogry.Items.Insert(0, new ListItem("-- Select Category --", ""));

                umLst               = umcon.SelectAllUnitOfMeasureInfo();
                ddlUM.DataSource    = umLst;
                ddlUM.DataTextField = "UMDescription";
                ddlUM.DataBind();
                ddlUM.Items.Insert(0, new ListItem("-- Select UM --", ""));
            }
        }
示例#5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            UnitOfMeasureInfo       sinfo = new UnitOfMeasureInfo();
            UnitOfMeasureController sCon  = new UnitOfMeasureController();
            string fn = @"D:\UMList.xlsx";

            FileStream fs = File.Open(fn, FileMode.Open, FileAccess.Read);

            IExcelDataReader ir = ExcelReaderFactory.CreateOpenXmlReader(fs);
            DataSet          ds = ir.AsDataSet();

            foreach (DataTable tobj in ds.Tables)
            {
                foreach (DataRow robj in tobj.Rows)
                {
                    sinfo.UMDescription = Convert.ToString(robj[0]);
                    sCon.InsertUnitOfMeasure(sinfo);
                }
            }
            ir.Close();
            fs.Close();
        }