예제 #1
0
        public void ShouldSetBestNewAge()
        {
            var service     = new MergeService(_dataAccess.Object, _repository.Object);
            var newCustomer = new MappedCustomerMessage
            {
                CustomerId = 1,
                SourceId   = 2,
                Data       = new Dictionary <string, Dictionary <string, object> > {
                    { "edad", new Dictionary <string, object> {
                          { "2", 36 }
                      } }
                }
            };
            var customerDocument = new CustomerDocument("1")
            {
                Data = new Dictionary <string, object> {
                    { "nombre", "cliente prueba" },
                    { "edad", 35 }
                },
                Full = JObject.Parse(elasticCustomer)
            };

            _dataAccess.Setup(x => x.Get <CustomerDocument>(It.IsAny <string>())).Returns(customerDocument);
            _dataAccess.Setup(x => x.Put(It.IsAny <CustomerDocument>()));
            service.Save("1", newCustomer);
            _dataAccess.Verify(x => x.Put(It.Is <CustomerDocument>(y => y.Data.Any(z => z.Key == "edad" && ((int)z.Value) == 36))));
        }
예제 #2
0
        public void ShouldCreateNewCustomer()
        {
            long sourceId    = 2;
            var  service     = new MergeService(_dataAccess.Object, _repository.Object);
            var  newCustomer = new MappedCustomerMessage
            {
                CustomerId = 1,
                SourceId   = sourceId,
                Data       = new Dictionary <string, Dictionary <string, object> > {
                    { "edad", new Dictionary <string, object> {
                          { sourceId.ToString(), 36 }
                      } },
                    { "nombre", new Dictionary <string, object> {
                          { sourceId.ToString(), "Nuevo cliente" }
                      } }
                }
            };

            _dataAccess.Setup(x => x.Get <CustomerDocument>(It.IsAny <string>()));
            _dataAccess.Setup(x => x.Put(It.IsAny <CustomerDocument>()));
            service.Save("1", newCustomer);
            _dataAccess.Verify(x => x.Put(It.Is <CustomerDocument>(y => y.Data.Any(z => z.Key == "nombre" && (z.Value.ToString()) == "Nuevo cliente"))));
            _dataAccess.Verify(x => x.Put(It.Is <CustomerDocument>(y => y.Data.Any(z => z.Key == "edad" && ((int)z.Value) == 36))));
        }