Beispiel #1
0
        public async Task Should_Error_Update_Data()
        {
            var dbContext = GetDbContext(GetCurrentMethod());
            var facade    = new GarmentPOMasterDistributionFacade(GetMockServiceProvider().Object, dbContext);

            var dataUtil = this.dataUtil(facade, dbContext);
            var data     = await dataUtil.GetTestData();

            var copiedData = dataUtil.CopyData(data);

            copiedData.Items = null;

            Exception e = await Assert.ThrowsAsync <Exception>(async() => await facade.Update(copiedData.Id, copiedData));

            Assert.NotNull(e.Message);
        }
Beispiel #2
0
        public async Task Should_Success_Update_Data()
        {
            var dbContext = GetDbContext(GetCurrentMethod());
            var facade    = new GarmentPOMasterDistributionFacade(GetMockServiceProvider().Object, dbContext);

            var dataUtil = this.dataUtil(facade, dbContext);
            var data     = await dataUtil.GetTestData();

            var copiedData = dataUtil.CopyData(data);

            copiedData.Items = new List <GarmentPOMasterDistributionItem>
            {
                data.Items.Select(i => {
                    var copiedItem = dataUtil.CopyDataItem(i);
                    if (i.Details != null)
                    {
                        var copiedDetail   = dataUtil.CopyDataDetail(i.Details.First());
                        var newDetail      = dataUtil.CopyDataDetail(i.Details.First());
                        newDetail.Id       = 0;
                        copiedItem.Details = new List <GarmentPOMasterDistributionDetail>
                        {
                            copiedDetail,
                            newDetail
                        };
                    }
                    return(copiedItem);
                }).First(),
                dataUtil.CopyDataItem(data.Items.Last())
            };

            //copiedData.Items = data.Items.Select(i =>
            //    {
            //        var copiedItem = dataUtil.CopyDataItem(i);
            //        if (i.Details != null)
            //        {
            //            copiedItem.Details = i.Details.Select(d => dataUtil.CopyDataDetail(d)).ToList();
            //        }
            //        return copiedItem;
            //    })
            //    .ToList();

            var Response = await facade.Update(copiedData.Id, copiedData);

            Assert.NotEqual(0, Response);
        }