public void Interactions_can_be_persisted_and_retrieved()
        {
            //Arrange
            var sutProvider = new DataProvider <Interaction>(_config, Interaction.ToDomainConverter);
            var columns     = sutProvider.LoadAllColumns();

            var sutPersister      = new InteractionPersister(columns, _config);
            var interactionRecord = TestData.Interactions.TakeSelfieWithPet;

            //Act
            ErrorMessage error;
            var          persistResult = sutPersister.TryPersist(ref interactionRecord, out error);

            //Assert
            Assert.IsTrue(persistResult);
            Assert.IsNull(error);

            //The new row id is assigned to ref of the object
            Assert.IsNotNull(interactionRecord.InteractionId);
            Assert.IsInstanceOf <int>(interactionRecord.InteractionId);

            var readResult = sutProvider.LoadAll().First();

            Assert.AreEqual(interactionRecord, readResult);
        }
Exemple #2
0
 public GameDataRequestProcessor(AnimalPersister animalPersister, AnimalMetricPersister animalMetricPersister, MetricPersister metricPersister, MetricInteractionPersister metricInteractionPersister, InteractionPersister interactionPersister)
 {
     this._animalPersister            = animalPersister;
     this._animalMetricPersister      = animalMetricPersister;
     this._metricPersister            = metricPersister;
     this._metricInteractionPersister = metricInteractionPersister;
     this._interactionPersister       = interactionPersister;
 }
        private bool PersistInteraction(out ErrorMessage error, ref Interaction persistedInteraction)
        {
            var provider  = new DataProvider <Interaction>(_config, Interaction.ToDomainConverter);
            var columns   = provider.LoadAllColumns();
            var persister = new InteractionPersister(columns, _config);

            return(persister.TryPersist(ref persistedInteraction, out error));
        }
Exemple #4
0
        public static GameDataState Initialize(IConfiguration config, IRepository <Animal, AnimalMetric> animals,
                                               IRepository <Metric, MetricInteraction> metrics, IRepository <Interaction, MetricInteraction> interactions,
                                               ResponseBuilder responseBuilder)
        {
            //Persisters
            var animalPersister            = new AnimalPersister(animals.ColumnInfo, config);
            var animalMetricPersister      = new AnimalMetricPersister(animals.JoinTableColumnInfo, config);
            var metricPersister            = new MetricPersister(metrics.ColumnInfo, config);
            var metricInteractionPersister = new MetricInteractionPersister(metrics.JoinTableColumnInfo, config);
            var interactionPersister       = new InteractionPersister(interactions.ColumnInfo, config);

            //Validators - TODO
            var gameDataRequestValidator = new GameDataRequestValidator();

            var requestProcessor = new GameDataRequestProcessor(animalPersister, animalMetricPersister, metricPersister,
                                                                metricInteractionPersister, interactionPersister);

            return(new GameDataState(animals, metrics, interactions, requestProcessor, responseBuilder,
                                     gameDataRequestValidator));
        }