public void Add_ValidEvent_Inserts(string rawEvent)
        {
            var postcrossingEvent = EventBaseHelper.MapToEventBase(rawEvent);

            var result = _eventRepository.Add(postcrossingEvent);

            Check.That(result).Not.IsNull();
            Check.That(MemoryRepositoryService.GetRepository().Database.GetCollection(PostcrossingTrackerConstants.EventCollectionName).Count()).IsEqualTo(1);
        }
        public void Add_NoRawEvent_DoesNotInsert(string rawEvent)
        {
            var postcrossingEvent = new EventBase
            {
                RawEvent = rawEvent
            };

            var result = _eventRepository.Add(postcrossingEvent);

            Check.That(result).IsNull();
            Check.That(MemoryRepositoryService.GetRepository().Database.GetCollection(PostcrossingTrackerConstants.EventCollectionName).Count()).IsEqualTo(0);
        }
Exemple #3
0
        private void GetOrAddTestHelper <T>(string referenceDataValue, T expectedReferenceData, bool insert = false, bool exists = false) where T : IReferenceData, new()
        {
            if (exists)
            {
                _referenceDataRepository.GetOrAdd <T>(expectedReferenceData.Value);
            }

            T referenceData = _referenceDataRepository.GetOrAdd <T>(referenceDataValue);

            if (!(expectedReferenceData is null))
            {
                Check.That(referenceData?.GetType()).IsEqualTo(typeof(T));
            }

            Check.That(referenceData?.Value).IsEqualTo(expectedReferenceData?.Value);

            if (insert || exists)
            {
                var referenceDataList = MemoryRepositoryService.GetRepository().Query <T>().ToList();

                Check.That(referenceDataList).CountIs(1);
                Check.That(referenceDataList[0].Value).IsEqualTo(referenceDataValue);
            }
        }