public void Create_Clone_MissingCloneMob()
        {
            var repo = new MobileRepository();

            repo.Create(1, "Test");
            Assert.Throws <InvalidDataException>(() => repo.Create(2, 5, "Test2"));
        }
        public void Create_DuplicateVnum()
        {
            var repo = new MobileRepository();

            repo.Create(1, "Test");
            Assert.Throws <DuplicateIndexException>(() => repo.Create(1, "Test2"));
        }
        /// <summary>
        /// 处理队列
        /// </summary>
        /// <param name="entity"></param>
        protected override bool Handle(QueueEntity entity)
        {
            var info = entity.Value.DeserializeJson <MobileEntity>();

            MobileRepository.Send(info);
            return(true);
        }
 /// <summary>
 /// 发送邮件
 /// </summary>
 /// <param name="info"></param>
 protected virtual void SendMobileMessage(CodeEntity info)
 {
     MobileRepository.Send(new MobileEntity
     {
         ToMobiles = new[] { info.ToAddress },
         Body      = info.Body
     });
 }
示例#5
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Write mobile phone company");
            string company = Console.ReadLine();

            MobileRepository repository = new MobileRepository();
            var mobile = repository.GetPhoneByCompany(company);
        }
        //[Test]
        public void Create()
        {
            var mobRepo = new MobileRepository();
            var mob     = mobRepo.Create(1, "TestMob");

            var repo   = new CharacterRepository();
            var actual = repo.Create(mob);

            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.ID, Is.GreaterThanOrEqualTo(1));
        }
示例#7
0
            public void ReturnNull_WhenNotFound()
            {
                var notFoundGlobalId = Guid.NewGuid();

                using var context = new MobilesContext(fixture.ContextOptions);
                sut = new MobileRepository(context, new EnumConverter(), new DateTimeCreator());

                var actual = sut.GetById(notFoundGlobalId);

                actual.Should().BeNull();
            }
        public void Create()
        {
            var repo = new MobileRepository();

            var actual = repo.Create(1, "Test");

            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.ID, Is.EqualTo(1));
            Assert.That(actual.Name, Is.EqualTo("Test"));
            Assert.That(actual.ShortDescription, Is.EqualTo("A newly created Test"));
            Assert.That(repo.Contains(1), Is.True);
        }
        public void Add(Mobile mobile)
        {
            var contextOptions = new DbContextOptionsBuilder <MobilesContext>()
                                 .UseSqlServer(ConfigurationData.ConnectionString)
                                 .Options;

            using var context = new MobilesContext(contextOptions);
            var mobilesRepository = new MobileRepository(context, new EnumConverter(), new DateTimeCreator());

            mobilesRepository.Add(mobile);
            mobilesAdded.Add(mobile);
        }
        public void Find()
        {
            var unitOfWork = new UnitOfWork();
            IMobileRepository mobileRepository = new MobileRepository(unitOfWork);

            var mobile = mobileRepository.Find(3);

            // var m = mobileRepository.All.Where(x => x.Brand.Contains("am")).ToList();

            //var m = mobileRepository.AllIncluding(x => x.Id == 3).SingleOrDefault(x => x.CurrencyId == 1);

            Assert.IsNotNull(mobile);
        }
示例#11
0
        /// <summary>
        /// 发送手机号码
        /// </summary>
        /// <param name="message"></param>
        protected virtual void SendMobileMesssage(MessageEntity message)
        {
            var account = Repository.Get <AccountEntity>(message.Task.Account.Id);

            if (account == null || string.IsNullOrEmpty(account.Mobile))
            {
                return;
            }
            var detail = message.Detail.Replace("【Remark】", message.Task.Remark).Replace("【Url】", message.Url);

            MobileRepository.Send(new MobileEntity {
                Variables = message.Task.Variables, Body = detail, ToMobiles = new[] { account.Mobile }
            });
        }
示例#12
0
            public void ReturnMobile()
            {
                var mobileBuilder  = new MobileBuilder();
                var expectedMobile = mobileBuilder
                                     .WithMobileState(Mobile.MobileState.New)
                                     .BuildWithoutOrder();

                mobiles.Add(expectedMobile);
                using var context = new MobilesContext(fixture.ContextOptions);
                sut = new MobileRepository(context, new EnumConverter(), new DateTimeCreator());
                sut.Add(expectedMobile);

                var actual = sut.GetById(expectedMobile.GlobalId);

                actual.Should().BeEquivalentTo(expectedMobile);
            }
示例#13
0
 public UnitOfWork(AppDbContext context)
 {
     _context          = context;
     Mobiles           = new MobileRepository(_context);
     Accessories       = new AccessoryRepository(_context);
     AccessoryTypes    = new AccessoryTypeRepository(_context);
     Brands            = new BrandRepository(_context);
     Vendors           = new VendorRepository(_context);
     Orders            = new OrderRepository(_context);
     OrderLineItems    = new OrderLineItemRepository(_context);
     Invoices          = new InvoiceRepository(_context);
     InvoiceLineItems  = new InvoiceLineItemRepository(_context);
     Categories        = new CategoryRepository(_context);
     Customers         = new CustomerRepository(_context);
     PurchaseOrders    = new PurchaseOrderRepository(_context);
     PurchaseLineItems = new PurchaseLineItemRepository(_context);
 }
        public void Create_CloneObject()
        {
            var repo = new MobileRepository();

            var source = repo.Create(1, "Test");

            source.LongDescription = "This is a test";

            var cloned = repo.Create(2, 1, "Test2");

            Assert.That(cloned, Is.Not.Null);
            Assert.That(cloned.ID, Is.EqualTo(2));
            Assert.That(cloned.Name, Is.EqualTo("Test2"));
            Assert.That(cloned.ShortDescription, Is.EqualTo("A newly created Test2"));
            Assert.That(cloned.LongDescription, Is.EqualTo(source.LongDescription));
            Assert.That(repo.Contains(2), Is.True);
        }
示例#15
0
            public void AddMobile()
            {
                var mobileBuilder = new MobileBuilder();

                expectedMobile = mobileBuilder
                                 .WithMobileState(Mobile.MobileState.Live)
                                 .WithOrderType(Order.OrderType.Activate)
                                 .WithOrderState(Order.State.Completed)
                                 .Build();
                using var context = new MobilesContext(fixture.ContextOptions);
                sut = new MobileRepository(context, new EnumConverter(), new DateTimeCreator());

                sut.Add(expectedMobile);

                var actual = sut.GetById(expectedMobile.GlobalId);

                actual.Should().BeEquivalentTo(expectedMobile);
            }
示例#16
0
            public void AddMobile()
            {
                var mobileBuilder = new MobileBuilder();

                expectedMobile = mobileBuilder
                                 .WithMobileState(Mobile.MobileState.New)
                                 .BuildWithoutOrder();
                using var context = new MobilesContext(fixture.ContextOptions);
                sut = new MobileRepository(context, new EnumConverter(), new DateTimeCreator());
                sut.Add(expectedMobile);

                expectedMobile.Provision();
                sut.Update(expectedMobile);

                var actual = sut.GetById(expectedMobile.GlobalId);

                actual.State.Should().Be(Mobile.MobileState.ProcessingProvision);
            }
示例#17
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("Beigin...");
            List <Mobile> mobiles = Crawler.SearchMobile(60, 1).ToList();

            Crawler.DisplayMobiles(mobiles);
            System.Console.WriteLine("数据爬取完成,共找到:{0}数据", mobiles.Count);

            System.Console.WriteLine("开始写入数据到MySql...");
            MobileRepository rep = new MobileRepository();

            rep.AddMobiles(mobiles);
            //clean up resource
            rep.Dispose();
            GC.Collect();
            mobiles.Clear();
            mobiles = null;

            System.Console.WriteLine("数据写入成功.任意键退出.");
            System.Console.ReadKey();
        }
示例#18
0
        /// <summary>
        /// 发送手机号码
        /// </summary>
        /// <param name="args"></param>
        /// <param name="message"></param>
        protected virtual void SendMobileMesssage(WorkflowArgsEntity args, MessageEntity message)
        {
            if ((args.Node.MessageType & (int)MessageType.Email) == 0 ||
                string.IsNullOrWhiteSpace(args.Node.MobileMessage))
            {
                return;
            }
            var account = Repository.Get <AccountEntity>(message.Account.Id);

            if (account == null || string.IsNullOrEmpty(account.Mobile))
            {
                return;
            }
            var url = ConfigurationManager.GetSetting <string>(args.Flow.Url);

            url = string.Format("{0}{1}", string.IsNullOrWhiteSpace(url) ? args.Flow.Url : url, args.Flow.MobileUrl);
            url = SignUrl(message, url);
            var detail = args.Node.MobileMessage.Replace("【Remark】", args.Remark).Replace("【Url】", url);

            MobileRepository.Send(new MobileEntity {
                Body = detail, ToMobiles = new[] { account.Mobile }
            });
        }
        public void Insert()
        {
            var unitOfWork = new UnitOfWork();
            IMobileRepository _mobileRepository = new MobileRepository(unitOfWork);


            //insert currencies

            _mobileRepository.Insert(new Mobile()
            {
                Name       = "Samsung J7 2016",
                Brand      = "Samsung",
                CommonName = "Samsung J7 2016",
                Model      = "J7 2016",
                UniqueName = "",
                Price      = 783
            });

            _mobileRepository.Insert(new Mobile()
            {
                Name       = "Samsung J5 2016",
                Brand      = "Samsung",
                CommonName = "Samsung J5 2016",
                Model      = "J5 2016",
                UniqueName = "",
                Price      = 783
            });


            unitOfWork.Save();

            // var mob = _mobileRepository.Find(1);

            // Assert.IsNotNull(mob);
            // Assert.AreEqual("Samsung", mob.Brand);
        }
 public MobileController(MobileRepository mobileRepository)
 {
     _mobileRepository = mobileRepository;
 }
示例#21
0
 public MobileController()
 {
     mobileRepository = new MobileRepository();
 }
        public void Create_ThrowsException()
        {
            var repo = new MobileRepository();

            Assert.Throws <ArgumentException>(() => repo.Create(1, ""));
        }
        public void Create_Clone_InvalidCloneVnum()
        {
            var repo = new MobileRepository();

            Assert.Throws <ArgumentException>(() => repo.Create(1, 1, "Test"));
        }
示例#24
0
 public MobileService()
 {
     mobileRepository = new MobileRepository();
 }