public void ShouldCallAddOnTheFormEventRepository()
        {
            // Arrange
            var formEvent = new FormEvent();
            _formEventRepository.Expect(x => x.Insert(formEvent));
            _formEventRepository.Replay();

            // Act
            var result = _formEventTrackingService.Add(formEvent);

            // Assert
            Assert.That(result, Is.EqualTo(formEvent));
            _formEventRepository.VerifyAllExpectations();
        }
        public void ShouldCallInsertForTheReplaceableAttributesSentIn()
        {
            // Arrange
            var formEvent = new FormEvent();
            var replaceableAttributes = new List<ReplaceableAttribute>();
            _entityMapper.Expect(x => x.Map<List<ReplaceableAttribute>>(formEvent)).Return(replaceableAttributes);
            _simpleDbProxy.Expect(x=> x.Put(FormEventRepository.DOMAIN_NAME, "", replaceableAttributes)).IgnoreArguments();

            _mockRepository.ReplayAll();

            // Act
            _formEventRepository.Insert(formEvent);

            // Assert
            _mockRepository.VerifyAll();
        }
        public void ShouldCallInsertForTheFormEventSentIn()
        {
            // Arrange
            var formEvent = new FormEvent();
            var formEventDataModel = new FormEventDataModel();
            _entityMapper.Expect(x => x.Map<FormEventDataModel>(formEvent)).Return(formEventDataModel);
            _mongoDbProxy.Expect(x => x.Insert(FormEventRepository.COLLECTION_NAME, new[] { formEventDataModel }));

            _mockRepository.ReplayAll();

            // Act
            _formEventRepository.Insert(formEvent);

            // Assert
            _mockRepository.VerifyAll();
        }
 protected List<ReplaceableAttribute> FormEventToReplaceableAttribute(FormEvent formEvent)
 {
     return new List<ReplaceableAttribute>(
         new[]
             {
                 new ReplaceableAttribute { Name = "Id", Value = formEvent.Id },
                 new ReplaceableAttribute { Name = "VisitGuid", Value = formEvent.VisitGuid.ToString() },
                 new ReplaceableAttribute { Name = "Url", Value = EnsureValue(formEvent.Url) },
                 new ReplaceableAttribute { Name = "PageId", Value = EnsureValue(formEvent.PageId) },
                 new ReplaceableAttribute { Name = "EventType", Value = EnsureValue(formEvent.EventType) },
                 new ReplaceableAttribute { Name = "ElementId", Value = EnsureValue(formEvent.ElementId) },
                 new ReplaceableAttribute { Name = "ElementValue", Value = EnsureValue(formEvent.ElementValue) },
                 new ReplaceableAttribute { Name = "ValueValid", Value = formEvent.ValueValid.ToString(CultureInfo.InvariantCulture) },
                 new ReplaceableAttribute { Name = "ClientDateTime", Value = formEvent.ClientDateTime.ToString(SimpleDbProxy.DATE_FORMAT_STRING) },
                 new ReplaceableAttribute { Name = "DateTime", Value = formEvent.DateTime.ToString(SimpleDbProxy.DATE_FORMAT_STRING) }
             }
         );
 }
        public void ShouldReturnJsonResult_FormEvent()
        {
            // Arrange
            var formEventPostModel = new FormEventPostModel();
            var formEvent = new FormEvent();

            _entityMapper.Expect(x => x.Map<FormEvent>(formEventPostModel)).Return(formEvent);
            _formEventTrackingService.Expect(x => x.Add(formEvent));

            _mockRepository.ReplayAll();

            // Act
            var jsonResult = _trackingController.FormEvent(formEventPostModel);

            // Assert
            Assert.That(jsonResult, Is.Not.Null);
            _mockRepository.VerifyAll();
        }
 public void Insert(FormEvent formEvent)
 {
     var formEventDataModel = EntityMapper.Map<FormEventDataModel>(formEvent);
     MongoDbProxy.Insert(CollectionName, new[] { formEventDataModel });
 }
 public void Insert(FormEvent formEvent)
 {
     formEvent.Id = Guid.NewGuid().ToString();
     var replaceableAttributes = _entityMapper.Map<List<ReplaceableAttribute>>(formEvent);
     _simpleDbProxy.Put(DOMAIN_NAME, formEvent.Id, replaceableAttributes);
 }
 public FormEvent Add(FormEvent formEvent)
 {
     _formEventRepository.Insert(formEvent);
     return formEvent;
 }