public void Product_Properties_Fires_PropertyChanged()
        {
            var product = new Product();

            product.AssertThatAllProperties()
                   .RaiseChangeNotification();
        }
        public void Exports_With_User_Defined_KeyValues_When_Available()
        {
            var service = new ExportService() as IExportService;
            var product = new Product { Id = Guid.NewGuid(), Name = "My Product", };
            var license = new License
            {
                LicenseType = LicenseType.Standard, 
                OwnerName = "License Owner", 
                ExpirationDate = null,
            };
            
            license.Data.Add(new UserData { Key = "KeyOne", Value = "ValueOne"});
            license.Data.Add(new UserData { Key = "KeyTwo", Value = "ValueTwo"});

            var path = Path.GetTempFileName();
            var file = new FileInfo(path);

            service.Export(product, license, file);

            var reader = file.OpenText();
            var content = reader.ReadToEnd();

            Assert.NotNull(content);
            Assert.Contains("KeyOne=\"ValueOne\"", content);
            Assert.Contains("KeyTwo=\"ValueTwo\"", content);
        }
예제 #3
0
        public void Export(Product product, License license, FileInfo path)
        {
            var generator = new LicenseGenerator(product.PrivateKey);
            var expiration = license.ExpirationDate.GetValueOrDefault(DateTime.MaxValue);
            var key = generator.Generate(license.OwnerName, license.ID, expiration, license.Data.ToDictionary(userData => userData.Key, userData => userData.Value), license.LicenseType);

            File.WriteAllText(path.FullName, key);
        }
        public void Exports_With_MaxDate_If_No_Expiration_Date_Is_Set()
        {
            var service = new ExportService() as IExportService;
            var product = new Product { Id = Guid.NewGuid(), Name = "My Product", };
            var license = new License { ID = Guid.NewGuid(), LicenseType = LicenseType.Standard, OwnerName = "License Owner", ExpirationDate = null };
            var path = Path.GetTempFileName();
            var file = new FileInfo(path);

            service.Export(product, license, file);

            var reader = file.OpenText();
            var content = reader.ReadToEnd();

            Assert.NotNull(content);
            Assert.Contains("expiration=\"9999-12-31T23:59:59.9999999\"", content);
        }
        public void Exports_LicenseInfo_To_File()
        {
            var service = new ExportService() as IExportService;
            var product = new Product { Id = Guid.NewGuid() };
            var license = new License { ID = Guid.NewGuid(), LicenseType = LicenseType.Standard, OwnerName = "License Owner", ExpirationDate = new DateTime(2020, 1, 1) };
            var path = Path.GetTempFileName();
            var file = new FileInfo(path);

            service.Export(product, license, file);

            var reader = file.OpenText();
            var content = reader.ReadToEnd();

            Assert.NotNull(content);
            Assert.Contains("<name>License Owner</name>", content);
            Assert.Contains("type=\"Standard\"", content);
            Assert.Contains("expiration=\"2020-01-01T00:00:00.0000000\"", content);
        }
예제 #6
0
 public Project()
 {
     _product = new Product();
 }