Beispiel #1
0
        public async void GetLicensesDataModel_FromInitializedDbTables_LogicLicensesDataModelEqualExpectedLicensesDataModel()
        {
            // arrange
            var products = GetProductsCatalog();
            var licenses = GetLicenses();

            fixture.db.ProductCatalog.AddRange(products);
            fixture.db.License.AddRange(licenses);
            await fixture.db.SaveChangesAsync();

            var expected = new LicensesDataModel
            {
                Id           = 44441,
                Date         = DateTime.UtcNow,
                GovermentNum = 4040414,
                ProductId    = 44440,
                ProductCAS   = 4040404,
                ProductName  = "Testin"
            };

            // act
            var actual = await logic.GetSingleDataModelAsync(expected.Id);

            // assert
            Assert.Equal(actual.Id, expected.Id);
            Assert.Equal(actual.Date, expected.Date);
            Assert.Equal(actual.GovermentNum, expected.GovermentNum);
            Assert.Equal(actual.ProductId, expected.ProductId);
            Assert.Equal(actual.ProductCAS, expected.ProductCAS);
            Assert.Equal(actual.ProductName, expected.ProductName);
        }
Beispiel #2
0
 /// <summary>
 /// Convert LicensesDataModel to LicensesViewModel
 /// </summary>
 /// <param name="licenseDataModel">Data model to be converted</param>
 /// <returns>Converted LicensesViewModel instance</returns>
 private LicensesViewModel LicensesDataModelToViewModel(LicensesDataModel licenseDataModel)
 {
     return(new LicensesViewModel
     {
         Id = licenseDataModel.Id,
         GovermentNum = licenseDataModel.GovermentNum,
         Date = licenseDataModel.Date.ToShortDateString(),
         ProductId = licenseDataModel.ProductId,
         ProductName = licenseDataModel.ProductName,
         ProductCAS = licenseDataModel.ProductCAS,
         IsValid = licenseValidation.IsValid(new License {
             Date = licenseDataModel.Date
         })
     });
 }