Пример #1
0
        public static IEnumerable <object[]> CreateAnnouncementData()
        {
            yield return(new object[] { EStatusCode.InvalidData, new CreateAnnouncement {
                                        } });

            yield return(new object[] { EStatusCode.InvalidData, new CreateAnnouncement {
                                            Id = RandomId.NewId()
                                        } });

            yield return(new object[] { EStatusCode.InvalidData, new CreateAnnouncement {
                                            Id = RandomId.NewId(), PricePurchase = 30000
                                        } });

            yield return(new object[] { EStatusCode.InvalidData, new CreateAnnouncement {
                                            Id = RandomId.NewId(), PricePurchase = 30000, PriceSale = 35000
                                        } });

            yield return(new object[] { EStatusCode.NotFound, new CreateAnnouncement {
                                            Id = RandomId.NewId(), PricePurchase = 30000, PriceSale = 35000, VehicleId = RandomId.NewId()
                                        }, false });

            yield return(new object[] { EStatusCode.Success, new CreateAnnouncement {
                                            Id = RandomId.NewId(), PricePurchase = 30000, PriceSale = 35000, VehicleId = RandomId.NewId()
                                        }, true });

            yield return(new object[] { EStatusCode.InvalidData, new CreateAnnouncement {
                                            Id = RandomId.NewId(), PricePurchase = 0, PriceSale = 35000, VehicleId = RandomId.NewId()
                                        }, true });

            yield return(new object[] { EStatusCode.InvalidData, new CreateAnnouncement {
                                            Id = RandomId.NewId(), PricePurchase = 30000, PriceSale = 0, VehicleId = RandomId.NewId()
                                        }, true });
        }
Пример #2
0
        public async void CreateAlbumTest()
        {
            var genreId  = RandomId.NewId();
            var objGenre = new Genre(genreId, "genre test");

            objGenre.AddCashbackConfig(new Domain.Models.Cashback(null, genreId, System.DayOfWeek.Monday, 10));
            await DbContext.Genres.AddAsync(objGenre);

            await DbContext.SaveChangesAsync();

            var id  = RandomId.NewId();
            var cmd = new CreateAlbumCommand()
            {
                Id        = id,
                Name      = "Test Genre 1",
                GenreId   = genreId,
                SpotifyId = null
            };

            var result = await CommandsHandler.Handle(cmd);

            var obj = await DbContext.Albums.Where(w => w.Id == id).FirstOrDefaultAsync();

            Assert.NotNull(result);
            Assert.NotNull(obj);
            Assert.Equal(ErrorCode.None, result.ErrorCode);
            Assert.Equal(id, obj.Id);
            Assert.True(result.Rows > 0);
        }
Пример #3
0
        public static IEnumerable <object[]> CreateVehicleData()
        {
            yield return(new object[] { EStatusCode.InvalidData, new CreateVehicle {
                                        } });

            yield return(new object[] { EStatusCode.InvalidData, new CreateVehicle {
                                            Id = RandomId.NewId()
                                        } });

            yield return(new object[] { EStatusCode.InvalidData, new CreateVehicle {
                                            Id = RandomId.NewId(), FuelId = EFuel.Flex
                                        } });

            yield return(new object[] { EStatusCode.InvalidData, new CreateVehicle {
                                            Id = RandomId.NewId(), FuelId = EFuel.Flex, ColorId = EColor.Black
                                        } });

            yield return(new object[] { EStatusCode.InvalidData, new CreateVehicle {
                                            Id = RandomId.NewId(), FuelId = EFuel.Flex, ColorId = EColor.Black, Year = 2010
                                        } });

            yield return(new object[] { EStatusCode.NotFound, new CreateVehicle {
                                            Id = RandomId.NewId(), FuelId = EFuel.Flex, ColorId = EColor.Black, Year = 2010, ModelId = RandomId.NewId(), Board = RandomId.NewId()
                                        }, false });

            yield return(new object[] { EStatusCode.Success, new CreateVehicle {
                                            Id = RandomId.NewId(), FuelId = EFuel.Flex, ColorId = EColor.Black, Year = 2010, ModelId = RandomId.NewId(), Board = RandomId.NewId()
                                        }, true });
        }
Пример #4
0
        public override void ToStream(Stream output)
        {
            output.Write(TLUtils.SignatureToBytes(Signature));
            output.Write(Flags.ToBytes());
            output.Write(RandomId.ToBytes());
            output.Write(TTL.ToBytes());
            output.Write(Message.ToBytes());
            ToStream(output, Media, Flags, (int)MessageFlags.Media);
            ToStream(output, Entities, Flags, (int)MessageFlags.Entities);
            ToStream(output, ViaBotName, Flags, (int)MessageFlags.ViaBotId);
            ToStream(output, ReplyToRandomMsgId, Flags, (int)MessageFlags.ReplyToMsgId);

            ChatId.NullableToStream(output);
            InputFile.NullableToStream(output);
            FromId.NullableToStream(output);
            Out.NullableToStream(output);
            Unread.NullableToStream(output);
            Date.NullableToStream(output);
            DeleteDate.NullableToStream(output);
            Qts.NullableToStream(output);

            var status = new TLInt((int)Status);

            output.Write(status.ToBytes());

            InSeqNo.NullableToStream(output);
            OutSeqNo.NullableToStream(output);
            CustomFlags.NullableToStream(output);

            if (IsSet(CustomFlags, (int)MessageCustomFlags.BotInlineResult))
            {
                _inlineBotResult.ToStream(output);
            }
        }
Пример #5
0
        public static IEnumerable <object[]> SellVehicleData()
        {
            yield return(new object[] { EStatusCode.InvalidData, new SellVehicle {
                                        } });

            yield return(new object[] { EStatusCode.InvalidData, new SellVehicle {
                                            Id = RandomId.NewId()
                                        } });

            yield return(new object[] { EStatusCode.NotFound, new SellVehicle {
                                            Id = RandomId.NewId(), DateSale = DateTime.Now
                                        }, false, false });

            yield return(new object[] { EStatusCode.NotFound, new SellVehicle {
                                            Id = RandomId.NewId(), DateSale = DateTime.Now
                                        }, true, false });

            yield return(new object[] { EStatusCode.NotFound, new SellVehicle {
                                            Id = RandomId.NewId(), DateSale = DateTime.Now
                                        }, false, true });

            yield return(new object[] { EStatusCode.Success, new SellVehicle {
                                            Id = RandomId.NewId(), DateSale = DateTime.Now
                                        }, true, true });
        }
Пример #6
0
        public override void ToStream(Stream output)
        {
            output.Write(TLUtils.SignatureToBytes(Signature));
            output.Write(RandomId.ToBytes());
            output.Write(TTL.ToBytes());
            //output.Write(RandomBytes.ToBytes());
            output.Write(Message.ToBytes());
            Media.ToStream(output);

            ChatId.NullableToStream(output);
            InputFile.NullableToStream(output);
            FromId.NullableToStream(output);
            Out.NullableToStream(output);
            Unread.NullableToStream(output);
            Date.NullableToStream(output);
            DeleteDate.NullableToStream(output);
            Qts.NullableToStream(output);

            var status = new TLInt((int)Status);

            output.Write(status.ToBytes());

            InSeqNo.NullableToStream(output);
            OutSeqNo.NullableToStream(output);
            CustomFlags.NullableToStream(output);
        }
Пример #7
0
        public static IEnumerable <object[]> UpdateModelData()
        {
            yield return(new object[] { EStatusCode.InvalidData, new UpdateModel {
                                        } });

            yield return(new object[] { EStatusCode.InvalidData, new UpdateModel {
                                            Id = RandomId.NewId()
                                        } });

            yield return(new object[] { EStatusCode.InvalidData, new UpdateModel {
                                            Id = RandomId.NewId(), Name = RandomId.NewId(250)
                                        } });

            yield return(new object[] { EStatusCode.NotFound, new UpdateModel {
                                            Id = RandomId.NewId(), Name = RandomId.NewId(200), BrandId = RandomId.NewId()
                                        }, true, false });

            yield return(new object[] { EStatusCode.NotFound, new UpdateModel {
                                            Id = RandomId.NewId(), Name = RandomId.NewId(200), BrandId = RandomId.NewId()
                                        }, false, true });

            yield return(new object[] { EStatusCode.Conflict, new UpdateModel {
                                            Id = RandomId.NewId(), Name = RandomId.NewId(200), BrandId = RandomId.NewId()
                                        }, true, true });

            yield return(new object[] { EStatusCode.Success, new UpdateModel {
                                            Id = RandomId.NewId(), Name = RandomId.NewId(200), BrandId = RandomId.NewId()
                                        }, true, true });
        }
Пример #8
0
        public async Task <MutationResult> ExecuteAsync(VehicleMutationsHandler handler)
        {
            var contact = await handler.DbContext.Contacts
                          .Where(c => c.Name == ContactName && c.Phone == ContactPhone)
                          .FirstOrDefaultAsync();

            if (contact == null)
            {
                contact = new Contact(
                    id: RandomId.NewId(),
                    name: ContactName,
                    phone: ContactPhone
                    );
                await handler.DbContext.AddAsync(contact);
            }

            var reservation = new Reservation(
                id: Id,
                contactId: contact.Id,
                announcementId: AnnouncementId
                );

            await handler.DbContext.AddAsync(reservation);

            var rows = await handler.DbContext.SaveChangesAsync();

            return(new MutationResult(rows));
        }
Пример #9
0
        public async void CreateGenreTest()
        {
            var id       = RandomId.NewId();
            var cashback = new List <CashbackCommand>();

            cashback.Add(new CashbackCommand()
            {
                Id = null, Percent = 15, DayOfWeek = System.DayOfWeek.Monday, GenreId = id
            });
            cashback.Add(new CashbackCommand()
            {
                Id = null, Percent = 10, DayOfWeek = System.DayOfWeek.Saturday, GenreId = id
            });
            cashback.Add(new CashbackCommand()
            {
                Id = null, Percent = 5, DayOfWeek = System.DayOfWeek.Sunday, GenreId = id
            });

            var cmd = new CreateGenreCommand()
            {
                Id       = id,
                Name     = "Test Genre 1",
                Cashback = cashback
            };

            var result = await CommandsHandler.Handle(cmd);

            var obj = await DbContext.Genres.Where(w => w.Id == id).FirstOrDefaultAsync();

            Assert.NotNull(result);
            Assert.NotNull(obj);
            Assert.Equal(ErrorCode.None, result.ErrorCode);
            Assert.Equal(id, obj.Id);
            Assert.True(result.Rows > 0);
        }
Пример #10
0
        public static IEnumerable <object[]> LoginUserData()
        {
            yield return(new object[] { EStatusCode.InvalidData, new LoginUser {
                                        } });

            yield return(new object[] { EStatusCode.InvalidData, new LoginUser {
                                            Login = RandomId.NewId(50)
                                        } });

            yield return(new object[] { EStatusCode.Unauthorized, new LoginUser {
                                            Login = RandomId.NewId(50), Password = RandomId.NewId(30)
                                        }, false });

            yield return(new object[] { EStatusCode.Unauthorized, new LoginUser {
                                            Login = RandomId.NewId(50), Password = RandomId.NewId(15)
                                        }, true, false });

            yield return(new object[] { EStatusCode.Success, new LoginUser {
                                            Login = RandomId.NewId(50), Password = RandomId.NewId(10)
                                        }, true, true });

            yield return(new object[] { EStatusCode.Success, new LoginUser {
                                            Login = RandomId.NewId(50), Password = RandomId.NewId(50)
                                        }, true, true });
        }
Пример #11
0
        public TaskItem()
        {
            InitializeComponent();
            this.PreviewMouseLeftButtonDown += TaskItem_MouseDown;
            string taskTitle = "任务:" + RandomId.GetRandomId();

            this.TitleExpander.Header = taskTitle;
        }
Пример #12
0
 public override byte[] ToBytes()
 {
     return(TLUtils.Combine(
                TLUtils.SignatureToBytes(Signature),
                RandomId.ToBytes(),
                RandomBytes.ToBytes(),
                Action.ToBytes()));
 }
Пример #13
0
 public Sale(
     string id,
     string customerName
     ) : this()
 {
     this.Id           = string.IsNullOrWhiteSpace(id) ? RandomId.NewId() : id;
     this.CustomerName = customerName;
 }
Пример #14
0
 public Album(string id, string spotifyId, string name, string genreId)
 {
     this.Id        = string.IsNullOrWhiteSpace(id) ? RandomId.NewId() : id;
     this.SpotifyId = spotifyId;
     this.Name      = name;
     this.Genre     = new Genre(genreId);
     this.Value     = Convert.ToDecimal(new Random().Next(1, 50));
 }
Пример #15
0
 public override byte[] ToBytes()
 {
     return(TLUtils.Combine(
                TLUtils.SignatureToBytes(Signature),
                Peer.ToBytes(),
                RandomId.ToBytes(),
                Data.ToBytes()));
 }
Пример #16
0
 public override void ToStream(Stream output)
 {
     output.Write(TLUtils.SignatureToBytes(Signature));
     RandomId.ToStream(output);
     ChatId.ToStream(output);
     Date.ToStream(output);
     Bytes.ToStream(output);
 }
Пример #17
0
 public Brand(
     string id,
     string name
     ) : this()
 {
     this.Id = string.IsNullOrWhiteSpace(id) ? RandomId.NewId() : id;
     this.SetData(name: name);
 }
Пример #18
0
 public void AddItem(SaleItem item)
 {
     if (item.Id == null)
     {
         item.Id = RandomId.NewId();
     }
     item.Sale = this;
     _items.Add(item);
 }
Пример #19
0
        public static IEnumerable <object[]> ListVehiclesData()
        {
            yield return(new object[] { EStatusCode.Success, new ListVehicles {
                                        } });

            yield return(new object[] { EStatusCode.Success, new ListVehicles {
                                            Year = 2010, BrandId = RandomId.NewId(), ModelId = RandomId.NewId(), FuelId = EFuel.Alcohol, ColorId = EColor.Black
                                        } });
        }
Пример #20
0
 public override byte[] ToBytes()
 {
     return(TLUtils.Combine(
                TLUtils.SignatureToBytes(Signature),
                Contacts.ToBytes(),
                RandomId.ToBytes(),
                Message.ToBytes(),
                Media.ToBytes()));
 }
Пример #21
0
        public override void ToStream(Stream output)
        {
            output.Write(TLUtils.SignatureToBytes(Signature));

            Bot.ToStream(output);
            Peer.ToStream(output);
            RandomId.ToStream(output);
            StartParam.ToStream(output);
        }
Пример #22
0
 public override byte[] ToBytes()
 {
     return(TLUtils.Combine(
                TLUtils.SignatureToBytes(Signature),
                UserId.ToBytes(),
                RandomId.ToBytes(),
                GAHash.ToBytes(),
                Protocol.ToBytes()));
 }
Пример #23
0
        public static IEnumerable <object[]> ListModelsSelectData()
        {
            yield return(new object[] { EStatusCode.Success, new ListModelsSelect {
                                        } });

            yield return(new object[] { EStatusCode.Success, new ListModelsSelect {
                                            BrandId = RandomId.NewId()
                                        } });
        }
        public override void ToStream(Stream output)
        {
            output.Write(TLUtils.SignatureToBytes(Signature));

            Peer.ToStream(output);
            RandomId.ToStream(output);
            Data.ToStream(output);
            File.ToStream(output);
        }
Пример #25
0
 public override void ToStream(Stream output)
 {
     output.Write(TLUtils.SignatureToBytes(Signature));
     Flags.ToStream(output);
     Media.ToStream(output);
     RandomId.ToStream(output);
     Message.ToStream(output);
     ToStream(output, Entities, Flags, (int)InputSingleMediaFlags.Entities);
 }
Пример #26
0
 public void AddCashbackConfig(Cashback cashback)
 {
     if (cashback.Id == null)
     {
         cashback.Id = RandomId.NewId();
     }
     cashback.Genre = this;
     this.Cashbacks.Add(cashback);
 }
Пример #27
0
        public override byte[] ToBytes()
        {
            System.Diagnostics.Debug.WriteLine("  <<TLDecryptedMessageService.ToBytes random_id={0} action=[{1}]", RandomId, Action);

            return(TLUtils.Combine(
                       TLUtils.SignatureToBytes(Signature),
                       RandomId.ToBytes(),
                       RandomBytes.ToBytes(),
                       Action.ToBytes()));
        }
Пример #28
0
        public static IEnumerable <object[]> GetVehiclePhotoData()
        {
            yield return(new object[] { EStatusCode.NotFound, new GetVehiclePhoto {
                                            Id = RandomId.NewId()
                                        }, false });

            yield return(new object[] { EStatusCode.Success, new GetVehiclePhoto {
                                            Id = RandomId.NewId()
                                        }, true });
        }
Пример #29
0
 public override byte[] ToBytes()
 {
     return(TLUtils.Combine(
                TLUtils.SignatureToBytes(Signature),
                Media.ToBytes(),
                Flags.ToBytes(),
                RandomId.ToBytes(),
                Message.ToBytes(),
                ToBytes(Entities, Flags, (int)InputSingleMediaFlags.Entities)));
 }
Пример #30
0
        public static IEnumerable <object[]> GetBrandData()
        {
            yield return(new object[] { EStatusCode.NotFound, new GetBrand {
                                            Id = RandomId.NewId()
                                        } });

            yield return(new object[] { EStatusCode.Success, new GetBrand {
                                            Id = RandomId.NewId()
                                        } });
        }