public void VerifyValidateAsyncOnce(ManufacturerId manufacturerId) { mock.Verify(i => i.ValidateAsync( manufacturerId, It.IsAny <CancellationToken>()), Times.Once); }
public static ManufacturerDefinition FromId(ManufacturerId id) { return(new ManufacturerDefinition { Id = id }); }
public IStoreItem CreateItem() { var itemCategoryId = new ItemCategoryId(CommonFixture.NextInt()); var manufacturerId = new ManufacturerId(CommonFixture.NextInt()); return(CreateItem(itemCategoryId, manufacturerId)); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) hashCode = hashCode * 59 + ManufacturerId.GetHashCode(); if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (CountryCode != null) { hashCode = hashCode * 59 + CountryCode.GetHashCode(); } if (Address != null) { hashCode = hashCode * 59 + Address.GetHashCode(); } if (Website != null) { hashCode = hashCode * 59 + Website.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if PatchProductRequestDto instances are equal /// </summary> /// <param name="other">Instance of PatchProductRequestDto to be compared</param> /// <returns>Boolean</returns> public bool Equals(PatchProductRequestDto other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( ManufacturerId == other.ManufacturerId || ManufacturerId != null && ManufacturerId.Equals(other.ManufacturerId) ) && ( CategoryId == other.CategoryId || CategoryId != null && CategoryId.Equals(other.CategoryId) ) && ( ProductName == other.ProductName || ProductName != null && other.ProductName != null && ProductName.SequenceEqual(other.ProductName) )); }
public override void WriteConsole(ConsoleOutputStyle style) { ConsoleOutputStyle = style; WriteConsoleHeader(false); WriteConsoleEntry("Manufacturer ID", ManufacturerId.ToString()); WriteConsoleEntry("Manufacturer Name", ManufacturerName); WriteConsoleEntry("Manufacturer Model", ManufacturerModel.ToString()); WriteConsoleEntry("Specification version", SpecificationVersion); WriteConsoleEntry("Specification level", SpecificationLevel.ToString()); WriteConsoleEntry("Specification revision", SpecificationRevision.ToString()); WriteConsoleEntry("Specification date", SpecificationDate.ToString("d")); WriteConsoleEntry("Platform-specific family", PlatformSpecificFamily); WriteConsoleEntry("Platform specification level", PlatformSpecificationLevel.ToString()); WriteConsoleEntry("Platform specification revision", PlatformSpecificationRevision.ToString()); WriteConsoleEntry("Platform specification date", PlatformSpecificationDate.ToString("d")); WriteConsoleEntry("Firmware version", FirmwareVersion.ToString()); WriteConsoleEntry("Physical presence version", PhysicalPresenceVersion); WriteConsoleEntry("Memory management", MemoryManagement); WriteConsoleEntry("Supported modes", SupportedModes); WriteConsoleEntry("Permanent attributes", PermanentAttributes); WriteConsoleEntry("Startup attributes", StartupAttributes); }
public bool Equals(Product other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(base.Equals(other) && string.Equals(Name, other.Name) && string.Equals(BarCode, other.BarCode) && Price == other.Price && string.Equals(Description, other.Description) && IsPublished == other.IsPublished && Equals(Dimensions, other.Dimensions) && ManufacturerId.Equals(other.ManufacturerId) && Equals(Pictures, other.Pictures) && CategoryId.Equals(other.CategoryId) && Equals(Category, other.Category) && ProductTypeId == other.ProductTypeId && Equals(ProductType, other.ProductType) && string.Equals(ExternalSourceName, other.ExternalSourceName) && string.Equals(ExternalId, other.ExternalId)); }
public void SetupFindByAsync(ManufacturerId manufacturerId, IManufacturer returnValue) { mock .Setup(i => i.FindByAsync( It.Is <ManufacturerId>(id => id == manufacturerId), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(returnValue)); }
private IStoreItem CreateItem(ItemCategoryId itemCategoryId, ManufacturerId manufacturerId) { var def = new StoreItemDefinition { ItemCategoryId = itemCategoryId, ManufacturerId = manufacturerId, Availabilities = StoreItemAvailabilityFixture.CreateManyValid(1) }; return(StoreItemFixture.CreateValid(def)); }
public int CompareTo(object obj) { UId id = obj as UId; if (id != null) { return(ManufacturerId.CompareTo(id.ManufacturerId) + DeviceId.CompareTo(id.DeviceId)); } return(-1); }
public void ItShouldFormatOtherParts() { var manufacturerId = ManufacturerId.Create("12345").should_be_valid(); var sut = new Kz09( manufacturerId, Kz09PartialString.Create("Consultant Name").should_be_valid(), None, None, None, Kz09PartialString.Create("Mandant Name").should_be_valid() ); sut.Formatted.Should().Be("12345*Consultant Name****Mandant Name"); }
public async Task ValidateAsync(ManufacturerId manufacturerId, CancellationToken cancellationToken) { if (manufacturerId is null) { throw new ArgumentNullException(nameof(manufacturerId)); } IManufacturer manufacturer = await manufacturerRepository .FindByAsync(manufacturerId, cancellationToken); cancellationToken.ThrowIfCancellationRequested(); if (manufacturer == null) { throw new DomainException(new ManufacturerNotFoundReason(manufacturerId)); } }
public ItemCreation(string name, string comment, QuantityType quantityType, float quantityInPacket, QuantityTypeInPacket quantityTypeInPacket, ItemCategoryId itemCategoryId, ManufacturerId manufacturerId, IEnumerable <IStoreItemAvailability> availabilities) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException($"'{nameof(name)}' cannot be null or whitespace", nameof(name)); } Name = name; Comment = comment; QuantityType = quantityType; QuantityInPacket = quantityInPacket; QuantityTypeInPacket = quantityTypeInPacket; ItemCategoryId = itemCategoryId ?? throw new ArgumentNullException(nameof(itemCategoryId)); ManufacturerId = manufacturerId; this.availabilities = availabilities ?? throw new ArgumentNullException(nameof(availabilities)); }
public async Task ValidateAsync_WithInvalidManufacturerId_ShouldThrowDomainException() { // Arrange var local = new LocalFixture(); var service = local.CreateService(); var manufacturerId = new ManufacturerId(local.CommonFixture.NextInt()); local.ManufacturerRepositoryMock.SetupFindByAsync(manufacturerId, null); // Act Func <Task> function = async() => await service.ValidateAsync(manufacturerId, default); // Assert using (new AssertionScope()) { (await function.Should().ThrowAsync <DomainException>()) .Where(ex => ex.Reason.ErrorCode == ErrorReasonCode.ManufacturerNotFound); } }
public async Task <IManufacturer> FindByAsync(ManufacturerId id, CancellationToken cancellationToken) { if (id == null) { throw new ArgumentNullException(nameof(id)); } var entity = await dbContext.Manufacturers.AsNoTracking() .FirstOrDefaultAsync(m => m.Id == id.Value); cancellationToken.ThrowIfCancellationRequested(); if (entity == null) { return(null); } return(toModelConverter.ToDomain(entity)); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (ManufacturerId != null) { hashCode = hashCode * 59 + ManufacturerId.GetHashCode(); } if (CategoryId != null) { hashCode = hashCode * 59 + CategoryId.GetHashCode(); } if (ProductName != null) { hashCode = hashCode * 59 + ProductName.GetHashCode(); } return(hashCode); } }
public override int GetHashCode() { unchecked { int hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (BarCode != null ? BarCode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Price.GetHashCode(); hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0); hashCode = (hashCode * 397) ^ IsPublished.GetHashCode(); hashCode = (hashCode * 397) ^ (Dimensions != null ? Dimensions.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ManufacturerId.GetHashCode(); hashCode = (hashCode * 397) ^ (Pictures != null ? Pictures.GetHashCode() : 0); hashCode = (hashCode * 397) ^ CategoryId.GetHashCode(); hashCode = (hashCode * 397) ^ (Category != null ? Category.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ProductTypeId; hashCode = (hashCode * 397) ^ (ProductType != null ? ProductType.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ExternalSourceName != null ? ExternalSourceName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ExternalId != null ? ExternalId.GetHashCode() : 0); return(hashCode); } }
public IStoreItem Create(ItemId id, string name, bool isDeleted, string comment, bool isTemporary, QuantityType quantityType, float quantityInPacket, QuantityTypeInPacket quantityTypeInPacket, ItemCategoryId itemCategoryId, ManufacturerId manufacturerId, IStoreItem predecessor, IEnumerable <IStoreItemAvailability> availabilities, TemporaryItemId temporaryId) { var item = new StoreItem( id, name, isDeleted, comment, isTemporary, quantityType, quantityInPacket, quantityTypeInPacket, itemCategoryId, manufacturerId, availabilities, temporaryId); item.SetPredecessor(predecessor); return(item); }
public StoreItem(ItemId id, string name, bool isDeleted, string comment, bool isTemporary, QuantityType quantityType, float quantityInPacket, QuantityTypeInPacket quantityTypeInPacket, ItemCategoryId itemCategoryId, ManufacturerId manufacturerId, IEnumerable <IStoreItemAvailability> availabilities, TemporaryItemId temporaryId) { Id = id ?? throw new ArgumentNullException(nameof(id)); Name = name; IsDeleted = isDeleted; Comment = comment; IsTemporary = isTemporary; QuantityType = quantityType; QuantityInPacket = quantityInPacket; QuantityTypeInPacket = quantityTypeInPacket; ItemCategoryId = itemCategoryId; ManufacturerId = manufacturerId; TemporaryId = temporaryId; this.availabilities = availabilities.ToList() ?? throw new ArgumentNullException(nameof(availabilities)); // predecessor must be explicitly set via SetPredecessor(...) due to this AutoFixture bug: // https://github.com/AutoFixture/AutoFixture/issues/1108 Predecessor = null; }
/// <summary> /// Returns true if ManufacturerInfoDto instances are equal /// </summary> /// <param name="other">Instance of ManufacturerInfoDto to be compared</param> /// <returns>Boolean</returns> public bool Equals(ManufacturerInfoDto other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( ManufacturerId == other.ManufacturerId || ManufacturerId.Equals(other.ManufacturerId) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( CountryCode == other.CountryCode || CountryCode != null && CountryCode.Equals(other.CountryCode) ) && ( Address == other.Address || Address != null && Address.Equals(other.Address) ) && ( Website == other.Website || Website != null && Website.Equals(other.Website) )); }
/// <summary> /// 将 UID 转为 16 进制字符串 /// </summary> /// <returns></returns> public override string ToString() { // 将 制造商ID 转为 4bti 字符串,设备ID 转为 8bit 字符串 return(string.Format("{0}:{1}", ManufacturerId.ToString("X4"), DeviceId.ToString("X8"))); }
/// <summary> /// Returns a System.String containing an Xml representation of the specified property of the current object /// </summary> /// <param name="property">name of a specific property that is to be written out as Xml. /// If this value is filled in, only the <id/> node and the node for property are output. /// At the time of this writing, this is only used for product_pictures. /// </param> /// <returns></returns> public string ToXml(string property) { var xml = new XElement(_objectName); xml.Add(new XElement("id", Id.ToString())); if ((property == null || property == "product_type_id") && LogBits.BitTest(Enums.Logfield.ProductTypeId)) { xml.Add(new XElement("product_type_id", (int)ProductTypeId)); } if ((property == null || property == "name_nl") && Name_NL != null && LogBits.BitTest(Enums.Logfield.PublicProductName_NL)) { xml.Add(new XElement("name_nl", Name_NL)); } //if ((property == null || property == "name_en") && Name_EN != null && LogBits.BitTest(Enums.Logfield.PublicProductName_EN)) // xml.Add(new XElement("name_en", Name_EN)); if ((property == null || property == "songs") && LogBits.BitTest(Enums.Logfield.SongSortOrder)) { xml.Add(new XElement("songs", from song in Songs select new XElement(XElement.Parse(song.ToXml())))); } if ((property == null || property == "subtitle_nl") && LogBits.BitTest(Enums.Logfield.Subtitle_NL)) { xml.Add(new XElement("subtitle_nl", Subtitle_NL)); } if ((property == null || property == "author_id") && LogBits.BitTest(Enums.Logfield.AuthorId)) { xml.Add(new XElement("author_id", AuthorId.ToString())); } if ((property == null || property == "arranger_id") && LogBits.BitTest(Enums.Logfield.ArrangerId)) { xml.Add(new XElement("arranger_id", ArrangerId.ToString())); } if ((property == null || property == "manufacturer_id") && LogBits.BitTest(Enums.Logfield.ManufacturerId)) { xml.Add(new XElement("manufacturer_id", ManufacturerId.ToString())); } if ((property == null || property == "instrument_id") && LogBits.BitTest(Enums.Logfield.InstrumentId)) { xml.Add(new XElement("instrument_id", InstrumentId.ToString())); } if ((property == null || property == "sell_price") && !SalesPrice.IsNullOrZero() && LogBits.BitTest(Enums.Logfield.SalesPrice)) { xml.Add(new XElement("sell_price", SalesPrice)); } if ((property == null || property == "reference") && LogBits.BitTest(Enums.Logfield.ReferenceNumber)) { xml.Add(new XElement("reference", ReferenceNumber)); } if ((property == null || property == "isbn") && LogBits.BitTest(Enums.Logfield.Isbn)) { xml.Add(new XElement("isbn", Isbn)); } if ((property == null || property == "ismn") && LogBits.BitTest(Enums.Logfield.Ismn)) { xml.Add(new XElement("ismn", Ismn)); } if ((property == null || property == "ean") && LogBits.BitTest(Enums.Logfield.Ean)) { xml.Add(new XElement("ean", Ean)); } if ((property == null || property == "upc") && LogBits.BitTest(Enums.Logfield.Upc)) { xml.Add(new XElement("upc", Upc)); } if ((property == null || property == "language_id") && LogBits.BitTest(Enums.Logfield.LanguageId)) { xml.Add(new XElement("language_id", LanguageId != null ? ((int)LanguageId).ToString() : String.Empty)); } if ((property == null || property == "binding_id") && LogBits.BitTest(Enums.Logfield.BindingId)) { xml.Add(new XElement("binding_id", BindingId.ToString())); } if ((property == null || property == "grade_level") && LogBits.BitTest(Enums.Logfield.GradeLevel)) { xml.Add(new XElement("grade_level", GradeLevel)); } if ((property == null || property == "product_series_id") && LogBits.BitTest(Enums.Logfield.SeriesId)) { xml.Add(new XElement("product_series_id", SeriesId.ToString())); } if ((property == null || property == "nr_of_pages") && LogBits.BitTest(Enums.Logfield.Pages)) { xml.Add(new XElement("nr_of_pages", Pages.ToString())); } if ((property == null || property == "tax_rate_id") && LogBits.BitTest(Enums.Logfield.TaxRateId)) { xml.Add(new XElement("tax_rate_id", ((int)TaxRateId).ToString())); } if ((property == null || property == "product_pictures") && LogBits.BitTest(Enums.Logfield.ProductPictureFilename)) { xml.Add(new XElement("product_pictures", from picture in ProductPictures select new XElement(XElement.Parse(picture.ToXml())))); } if ((property == null || property == "description_nl") && LogBits.BitTest(Enums.Logfield.Description_NL)) { xml.Add(new XElement("description_nl", Description_NL)); } if ((property == null || property == "weight") && LogBits.BitTest(Enums.Logfield.Weight)) { xml.Add(new XElement("weight", Weight.ToString())); } if ((property == null || property == "length") && LogBits.BitTest(Enums.Logfield.Length)) { xml.Add(new XElement("length", Length.ToString())); } if ((property == null || property == "width") && LogBits.BitTest(Enums.Logfield.Width)) { xml.Add(new XElement("width", Width.ToString())); } if ((property == null || property == "height") && LogBits.BitTest(Enums.Logfield.Height)) { xml.Add(new XElement("height", Height.ToString())); } if ((property == null || property == "product_categories") && LogBits.BitTest(Enums.Logfield.ProductCategory)) { xml.Add(new XElement("product_categories", from category in ProductCategories select new XElement("product_category", new XElement("id", category.Id), new XElement("test", Test.ToInt())))); } if ((property == null || property == "internal_stock_qty") && LogBits.BitTest(Enums.Logfield.InternalStock)) { xml.Add(new XElement("internal_stock_qty", InternalStock.ToString())); } if ((property == null || property == "external_stock_qty") && LogBits.BitTest(Enums.Logfield.ExternalStock)) { xml.Add(new XElement("external_stock_qty", ExternalStock != null ? ExternalStock.ToString() : "1")); } if ((property == null || property == "supplier_id") && LogBits.BitTest(Enums.Logfield.SupplierId)) { xml.Add(new XElement("supplier_id", SupplierId.ToString())); } if ((property == null || property == "promotion") && LogBits.BitTest(Enums.Logfield.Promotion)) { xml.Add(new XElement("promotion", Promotion.ToInt().ToString())); } if ((property == null || property == "highlight_on_home") && LogBits.BitTest(Enums.Logfield.HighlightOnHome)) { xml.Add(new XElement("highlight_on_home", HighlightOnHome.ToInt().ToString())); } if ((property == null || property == "available") && LogBits.BitTest(Enums.Logfield.ActiveInWebshop)) { xml.Add(new XElement("available", ActiveInWebshop.ToInt().ToString())); } if ((property == null || property == "bestseller") && LogBits.BitTest(Enums.Logfield.BestSeller)) { xml.Add(new XElement("bestseller", BestSeller.ToInt().ToString())); } if ((property == null || property == "minimum_order_qty") && LogBits.BitTest(Enums.Logfield.MinimumOrderQty)) { xml.Add(new XElement("minimum_order_qty", (MinimumOrderQuantity != 0) ? MinimumOrderQuantity.ToString() : String.Empty)); } if ((property == null || property == "teacher_discount") && LogBits.BitTest(Enums.Logfield.WebshopTeacherDiscount)) { xml.Add(new XElement("teacher_discount", TeacherDiscount.ToString())); } if ((property == null || property == "reseller_discount") && LogBits.BitTest(Enums.Logfield.WebshopResellerDiscount)) { xml.Add(new XElement("reseller_discount", ResellerDiscount.ToString())); } if ((property == null || property == "search_keywords") && LogBits.BitTest(Enums.Logfield.SearchKeywords)) { xml.Add(new XElement("search_keywords", SearchKeywords)); } if ((property == null || property == "store_pickup_only") && LogBits.BitTest(Enums.Logfield.StorePickupOnly)) { xml.Add(new XElement("store_pickup_only", StorePickupOnly.ToInt().ToString())); } if ((property == null || property == "test")) { xml.Add(new XElement("test", Test.ToInt())); } if ((property == null || property == "created") && LogBits.BitTest(Enums.Logfield.CreateDttm)) { xml.Add(new XElement("created", (!CreatedDttm.IsNullOrDefault()) ? ((DateTime)CreatedDttm).ToString("yyyy-MM-dd HH:mm:ss") : String.Empty)); } if ((property == null || property == "updated") && LogBits.BitTest(Enums.Logfield.UpdateDttm)) { xml.Add(new XElement("updated", (!UpdatedDttm.IsNullOrDefault()) ? ((DateTime)UpdatedDttm).ToString("yyyy-MM-dd HH:mm:ss") : String.Empty)); } if ((property == null || property == "deleted") && LogBits.BitTest(Enums.Logfield.DeleteDttm)) { xml.Add(new XElement("deleted", (!DeletedDttm.IsNullOrDefault()) ? ((DateTime)DeletedDttm).ToString("yyyy-MM-dd HH:mm:ss") : String.Empty)); } string xmlString = xml.ToString(); return(xmlString); }
public void ItShouldFormatManufacturerOnlyCorrectly() { var sut = Kz09.Manufacturer(ManufacturerId.Create("12345").should_be_valid()); sut.Formatted.Should().Be("12345"); }
public Manufacturer(ManufacturerId id, string name, bool isDeleted) { Id = id; Name = name; IsDeleted = isDeleted; }
Int32 DisplayManufacturers(string ManufacturerNameFilter) { Int32 ManufacturerId; //var to store the primary key String ManufacturerName; //var to store the Device Name String Address; //var to store the Device Name Int32 Telephone; //var to store the primary key String EmailAddress; // ; //create an instance of the phone class clsManufacturerCollection Manufacturer = new clsManufacturerCollection(); Manufacturer.ReportByManufacturerName(ManufacturerNameFilter); Int32 RecordCount; //var to store the count of records Int32 Index = 0; //var to store the index for the loop RecordCount = Manufacturer.Count; // get the count of records lstManufacturers.Items.Clear(); //clear the list box while (Index < RecordCount) //while there are records to process { ManufacturerId = Manufacturer.ManufacturerList[Index].ManufacturerId; //get the primary key ManufacturerName = Manufacturer.ManufacturerList[Index].ManufacturerName; //get the Device Name Address = Manufacturer.ManufacturerList[Index].Address; //get the Operating System Telephone = Manufacturer.ManufacturerList[Index].Telephone; //get the Price EmailAddress = Manufacturer.ManufacturerList[Index].EmailAddress; //get email address ListItem NewEntry = new ListItem(ManufacturerName + ", " + Telephone.ToString() + ", " + Address + ",", ManufacturerId.ToString()); lstManufacturers.Items.Add(NewEntry); //add the phone to the list Index++; //move the index to the next record } return(RecordCount); //return the count of the records found }
internal DeviceIdentity(byte rawDeviceId, ManufacturerId manufacturerId, int familyCode, int familyNumberCode, int softwareRevision) => (RawDeviceId, ManufacturerId, FamilyCode, FamilyNumberCode, SoftwareRevision) =
public DeviceInfo(int localDeviceId, string name, ManufacturerId manufacturerId, short productId) => (LocalDeviceId, Name, ManufacturerId, ProductId) = (localDeviceId, name, manufacturerId, productId);
/// <summary> /// 获取 UID 哈希值 /// </summary> /// <returns></returns> public override int GetHashCode() { return(ManufacturerId.GetHashCode() + DeviceId.GetHashCode()); }
public ManufacturerNotFoundReason(ManufacturerId id) { Message = $"Manufacturer {id.Value} not found."; }
public override string ToString() { return(string.Format("{0}:{1}", ManufacturerId.ToString("X4"), DeviceId.ToString("X8"))); }