コード例 #1
0
        public async void CreateAsync_Should_Return_Correct_Data()
        {
            const string id = "123";
            //arrange
            var mockedRepo       = new Mock <IGenericRepository <SubmissionVM> >();
            var mockedConfigRepo = new Mock <IGenericRepository <ConfigVM> >();
            var mockedConfig     = new Mock <IAppConfiguration <ConfigVM> >();
            var sut = new SubmissionService(mockedRepo.Object, mockedConfigRepo.Object, mockedConfig.Object);

            mockedRepo.Setup(x => x.CreateAsync(It.IsAny <SubmissionVM>())).ReturnsAsync(new SubmissionVM {
                Id = id
            });
            //act
            var result = await sut.CreateAsync(new SubmissionVM { Id = id });

            //assert
            result.Id.Should().Be(id);
        }
コード例 #2
0
        public async void CreateAsync_Should_Not_Be_null()
        {
            const string id = "123";
            //arrange
            var mockedRepo       = new Mock <IGenericRepository <SubmissionVM> >();
            var mockedConfigRepo = new Mock <IGenericRepository <ConfigVM> >();
            var mockedConfig     = new Mock <IAppConfiguration <ConfigVM> >();
            //var mockedIdGenerator = new Mock<IUidGeneratorService>();
            var mockedAppSettings = new Mock <IConfiguration>();
            var sut = new SubmissionService(mockedRepo.Object, mockedConfigRepo.Object, mockedConfig.Object, mockedAppSettings.Object);

            mockedRepo.Setup(x => x.CreateAsync(It.IsAny <SubmissionVM>())).ReturnsAsync(new SubmissionVM {
                Id = id
            });
            //act
            var result = await sut.CreateAsync(new SubmissionVM { Id = id });

            //assert
            result.Should().NotBeNull();
        }
コード例 #3
0
        public async void CreateAsync_Should_Return_Correct_Data()
        {
            const string id = "123";
            //arrange
            var mockedRepo = new Mock <IGenericRepository <SubmissionVM> >();
            var mockedServiceBusService = new Mock <IServiceBusService>();
            var mockedJobClient         = new Mock <IBackgroundJobClient>();
            var mockedConfigRepo        = new Mock <IGenericRepository <ConfigVM> >();
            var mockedConfig            = new Mock <IAppConfiguration <ConfigVM> >();
            var mockedAppSettings       = new Mock <IConfiguration>();
            //var mockedIdGenerator = new Mock<IUidGeneratorService>();
            var sut = new SubmissionService(mockedRepo.Object, mockedServiceBusService.Object, mockedJobClient.Object);     //, mockedConfigRepo.Object, mockedConfig.Object, mockedAppSettings.Object);

            mockedRepo.Setup(x => x.CreateAsync(It.IsAny <SubmissionVM>())).ReturnsAsync(new SubmissionVM {
                Id = id
            });
            //act
            var result = await sut.CreateAsync(new SubmissionVM { Id = id });

            //assert
            result.Id.Should().Be(id);
        }