Beispiel #1
0
        public async void GetProducerRegistration_GivenProducerRegistration_ReturnsProducerRegistration()
        {
            using (var databaseWrapper = new DatabaseWrapper())
            {
                // Arrange
                var modelHelper = new ModelHelper(databaseWrapper.Model);

                var organisation       = modelHelper.CreateOrganisation();
                var scheme             = modelHelper.CreateScheme(organisation);
                var registeredProducer = modelHelper.GetOrCreateRegisteredProducer(scheme, 2019, "registrationNumber");
                //var producerSubmission = new ProducerSubmission();
                //producerSubmission.RegisteredProducer = registeredProducer;
                //databaseWrapper.Model.ProducerSubmissions.Add(producerSubmission);

                await databaseWrapper.Model.SaveChangesAsync();

                // Act
                var dataAccess = new RegisteredProducerDataAccess(databaseWrapper.WeeeContext);

                var result = await dataAccess.GetProducerRegistration(registeredProducer.ProducerRegistrationNumber, 2019, scheme.ApprovalNumber);

                // Assert
                Assert.Equal(registeredProducer.Id, result.Id);
            }
        }
        public async Task GetProducerRegistration_GivenMultipleResults_ArgumentExceptionShouldBeThrown()
        {
            var registeredProducers = new List <RegisteredProducer> {
                RegisteredProducer(ComplianceYear), RegisteredProducer(ComplianceYear)
            };

            A.CallTo(() => context.RegisteredProducers).Returns(dbHelper.GetAsyncEnabledDbSet(registeredProducers));

            Func <Task> action = async() =>
                                 await dataAccess.GetProducerRegistration(ProducerRegistrationNumber, ComplianceYear, SchemeApprovalNumber);

            await Assert.ThrowsAsync <ArgumentException>(action);
        }