Beispiel #1
0
        private static void FackProductComment(MyUnitTestData testData,
                                               Mock <IDtoLoaderConfigurationProvider> fakeProfile)
        {
            var fakeRule = new Mock <IDtoLoadRule>();

            fakeRule.Setup(x => x.LoadAsObjectAsync(It.IsAny <IServiceProvider>(), It.IsAny <IEnumerable <object> >()))
            .Returns <IServiceProvider, IEnumerable <object> >((serviceProvider, ids) =>
            {
                return(Task.FromResult(testData.ProductCommentDtos.Where(x => ids.Contains(x.Id))
                                       .Select(x => (object)x)));
            });

            fakeRule.Setup(x => x.GetKey(It.IsAny <object>()))
            .Returns <object>(x => { return(((ProductCommentDto)x).Id); });

            fakeProfile.Setup(x => x.GetLoadRule(typeof(ProductCommentDto)))
            .Returns(fakeRule.Object);
        }
Beispiel #2
0
        private static RelatedDtoLoader.RelatedDtoLoader GetRelatedDtoLoader(MyUnitTestData testData)
        {
            var fakeConfig = new Mock <IDtoLoaderConfigurationProvider>();

            var fakeProfile = new Mock <IRelatedDtoLoaderProfile>();

            FackProduct(testData, fakeConfig);
            FackProductComment(testData, fakeConfig);

            var orderRelatedDtoProperties = new RelatedDtoPropertyCollection(typeof(OrderDto));

            fakeConfig.Setup(x => x.GetRelatedDtoProperties(typeof(OrderDto)))
            .Returns(orderRelatedDtoProperties);

            var dtoLoader = new RelatedDtoLoader.RelatedDtoLoader(null, fakeConfig.Object);

            return(dtoLoader);
        }