protected override void Initialize(HttpControllerContext controllerContext)
        {
            base.Initialize(controllerContext);
            ClaimsDbContext context = new ClaimsDbContext();

            DomainManager = new EntityDomainManager <Claim>(context, Request);
        }
        public void ReturnCollectionOfClaimsFilteredByAirline()
        {
            // Arrange
            var options = TestUtilities.GetOptions(nameof(ReturnCollectionOfClaimsFilteredByAirline));

            // Act, Assert
            using (var assertContext = new ClaimsDbContext(options))
            {
                var       myProfile     = new ClaimProfile();
                var       configuration = new MapperConfiguration(cfg => cfg.AddProfile(myProfile));
                IMapper   mapper        = new Mapper(configuration);
                var       claimDto      = new ClaimDto();
                var       claimDto2     = new ClaimDto();
                var       claimDto3     = new ClaimDto();
                IFormFile file          = new FormFile(new MemoryStream(Encoding.UTF8.GetBytes("This is a dummy file")), 0, 0, "Data", "dummy.txt");
                claimDto.BPImage  = file;
                claimDto2.BPImage = file;
                claimDto3.BPImage = file;
                claimDto.Airline  = "TestAir";
                claimDto2.Airline = "TestAir";
                claimDto3.Airline = "AirTest";
                var sut = new ClaimServices(assertContext, mapper);
                sut.CreateAsync(claimDto).GetAwaiter().GetResult();
                sut.CreateAsync(claimDto2).GetAwaiter().GetResult();
                sut.CreateAsync(claimDto3).GetAwaiter().GetResult();
                var results = sut.FilterByMultipleCriteriaAsync("TestAir", default, default, default).GetAwaiter().GetResult();
        public void AddTheClaimToTheDBSetCorrectly()
        {
            // Arrange
            var options = TestUtilities.GetOptions(nameof(AddTheClaimToTheDBSetCorrectly));

            // Act, Assert
            using (var assertContext = new ClaimsDbContext(options))
            {
                var       myProfile     = new ClaimProfile();
                var       configuration = new MapperConfiguration(cfg => cfg.AddProfile(myProfile));
                IMapper   mapper        = new Mapper(configuration);
                var       claimDto      = new ClaimDto();
                IFormFile file          = new FormFile(new MemoryStream(Encoding.UTF8.GetBytes("This is a dummy file")), 0, 0, "Data", "dummy.txt");
                claimDto.BPImage = file;
                var sut        = new ClaimServices(assertContext, mapper);
                var testResult = sut.CreateAsync(claimDto).GetAwaiter().GetResult();

                Assert.IsTrue(assertContext.Claims.Count() == 1 && assertContext.Claims.Any(c => c.Id == testResult.Id));
            }
        }
        public void CreateNewInstanceOfClaimDto()
        {
            // Arrange
            var options = TestUtilities.GetOptions(nameof(CreateNewInstanceOfClaimDto));

            // Act, Assert
            using (var assertContext = new ClaimsDbContext(options))
            {
                var       myProfile     = new ClaimProfile();
                var       configuration = new MapperConfiguration(cfg => cfg.AddProfile(myProfile));
                IMapper   mapper        = new Mapper(configuration);
                var       claimDto      = new ClaimDto();
                IFormFile file          = new FormFile(new MemoryStream(Encoding.UTF8.GetBytes("This is a dummy file")), 0, 0, "Data", "dummy.txt");
                claimDto.BPImage = file;
                var sut        = new ClaimServices(assertContext, mapper);
                var testResult = sut.CreateAsync(claimDto).GetAwaiter().GetResult();

                Assert.IsInstanceOfType(testResult, typeof(ClaimDto));
            }
        }
Beispiel #5
0
        public void ReturnCollectionOfUpTo20NewestClaims()
        {
            // Arrange
            var options = TestUtilities.GetOptions(nameof(ReturnCollectionOfUpTo20NewestClaims));

            // Act, Assert
            using (var assertContext = new ClaimsDbContext(options))
            {
                var       myProfile     = new ClaimProfile();
                var       configuration = new MapperConfiguration(cfg => cfg.AddProfile(myProfile));
                IMapper   mapper        = new Mapper(configuration);
                IFormFile file          = new FormFile(new MemoryStream(Encoding.UTF8.GetBytes("This is a dummy file")), 0, 0, "Data", "dummy.txt");
                var       claimDto      = new ClaimDto();
                claimDto.BPImage = file;
                var claimDto2 = new ClaimDto();
                claimDto2.BPImage = file;
                var sut = new ClaimServices(assertContext, mapper);
                sut.CreateAsync(claimDto).GetAwaiter().GetResult();
                sut.CreateAsync(claimDto2).GetAwaiter().GetResult();
                var testResult = sut.Get20LatestClaimsAsync().GetAwaiter().GetResult();

                Assert.IsTrue(testResult.Count() == 2 && testResult[0].CreatedAt > testResult[1].CreatedAt);
            }
        }
 public ClaimStorageController()
     : base(new DefaultStorageProvider())
 {
     this.claimsDbContext       = new ClaimsDbContext();
     this.containerNameResolver = new DefaultContainerNameResolver();
 }
Beispiel #7
0
        public void Setup()
        {
            var options = new DbContextOptionsBuilder <ClaimsDbContext>().UseNpgsql("User ID=netcore;Password=Welcome123!;Server=192.168.1.251;Port=5432;Database=claims_db;Integrated Security=true; Pooling=true;ApplicationName=claims_db;").Options;

            _dbcontext = new ClaimsDbContext(options);
        }
Beispiel #8
0
        public static void Initialize(ClaimsDbContext context)
        {
            context.Database.EnsureCreated();

            context.SaveChanges();
        }
 public ClaimsController()
 {
     dbContext = new ClaimsDbContext();
 }
Beispiel #10
0
 public ClaimController(ClaimsDbContext claimsDbContext)
 {
     _claimsDbContext = claimsDbContext;
 }
Beispiel #11
0
 public ClaimServices(ClaimsDbContext context, IMapper mapper)
 {
     this.context = context;
     this.mapper  = mapper;
 }