コード例 #1
0
ファイル: Program.cs プロジェクト: bsogulcan/DtoGenerator
        static void Main(string[] args)
        {
            if (!ArgsChecker(args))
            {
                return;
            }

            if (_inputDirectory == string.Empty)
            {
                Console.WriteLine("Enter the file path:");
                _inputDirectory = Console.ReadLine();
            }

            if (_outputDirectory == string.Empty)
            {
                Console.WriteLine("Enter endpoint:");
                _outputDirectory = Console.ReadLine();
            }

            Setting setting = new Setting(_processType, _frameworkType, _inputDirectory, _outputDirectory,
                                          _fileName, _buildAll, _buildFullOutput, _buildPartOutput, _buildCreateInput, _buildUpdateInput,
                                          _buildGetInput, _buildDeleteInput);

            if (_processType == ProcessType.Dto)
            {
                DtoBuilder.DtoBuild(setting);
            }
        }
コード例 #2
0
ファイル: AdminLogin.cs プロジェクト: hiwamn/Mukta
        public LoginResultDto Execute(LoginDto dto)
        {
            User           user   = unit.User.GetByEmailIncludingRoles(dto.Email);
            LoginResultDto result = new LoginResultDto();

            if (user == null)
            {
                result.Message = Messages.UserNotExist;
            }
            else if (!user.ValidatePassword(dto.Password, _encrypter))
            {
                result.Message = Messages.InvalidPassword;
            }
            else if (user.Status != Enums.EntityStatus.Active.ToInt())
            {
                result.Message = Messages.UserNotActivated;
            }
            else if (user.UserRole == null || !user.UserRole.Any(p => p.RoleId == Roles.Admin.ToInt()))
            {
                result.Message = Messages.AccessDenied;
            }
            else
            {
                result.Object       = DtoBuilder.CreateLoginDto(user);
                result.Object.Token = _jwtHandler.Create(user.Id);
                result.Status       = true;
            }
            return(result);
        }
コード例 #3
0
ファイル: AddEntityCommand.cs プロジェクト: wi3land/craftsman
        private static void RunEntityBuilders(string solutionDirectory, ApiTemplate template, IFileSystem fileSystem)
        {
            //entities
            foreach (var entity in template.Entities)
            {
                EntityBuilder.CreateEntity(solutionDirectory, entity, fileSystem);
                DtoBuilder.CreateDtos(solutionDirectory, entity);

                RepositoryBuilder.AddRepository(solutionDirectory, entity, template.DbContext);
                ValidatorBuilder.CreateValidators(solutionDirectory, entity);
                ProfileBuilder.CreateProfile(solutionDirectory, entity);

                ControllerBuilder.CreateController(solutionDirectory, entity, template.SwaggerConfig.AddSwaggerComments, template.AuthorizationSettings.Policies);
                InfrastructureIdentityServiceRegistrationModifier.AddPolicies(solutionDirectory, template.AuthorizationSettings.Policies);

                FakesBuilder.CreateFakes(solutionDirectory, template.SolutionName, entity);
                ReadTestBuilder.CreateEntityReadTests(solutionDirectory, template.SolutionName, entity, template.DbContext.ContextName);
                GetTestBuilder.CreateEntityGetTests(solutionDirectory, template.SolutionName, entity, template.DbContext.ContextName, template.AuthorizationSettings.Policies);
                PostTestBuilder.CreateEntityWriteTests(solutionDirectory, entity, template.SolutionName, template.AuthorizationSettings.Policies);
                UpdateTestBuilder.CreateEntityUpdateTests(solutionDirectory, entity, template.SolutionName, template.DbContext.ContextName, template.AuthorizationSettings.Policies);
                DeleteIntegrationTestBuilder.CreateEntityDeleteTests(solutionDirectory, entity, template.SolutionName, template.DbContext.ContextName, template.AuthorizationSettings.Policies);
                DeleteTestBuilder.DeleteEntityWriteTests(solutionDirectory, entity, template.SolutionName, template.DbContext.ContextName);
            }

            //seeders & dbsets
            SeederModifier.AddSeeders(solutionDirectory, template.Entities, template.DbContext.ContextName);
            DbContextModifier.AddDbSet(solutionDirectory, template.Entities, template.DbContext.ContextName);
        }
コード例 #4
0
        public void Test(Type type, int repeatTimes, TimeSpan duration)
        {
            var builder = new DtoBuilder();
            var ins     = builder.Create(type);

            HeatUp(ins);

            var counters = new int[repeatTimes];

            for (var i = 0; i < repeatTimes; i++)
            {
                var counter   = 0;
                var stopWatch = new Stopwatch();
                stopWatch.Start();
                while (stopWatch.Elapsed < duration)
                {
                    var memoryStream = WriteDto(ins);
                    Assert.True(memoryStream.Length > 0);
                    counter++;
                }

                stopWatch.Stop();
                counters[i] = counter;
            }

            var min     = counters.Min();
            var max     = counters.Max();
            var avg     = counters.Average();
            var diff    = (double)(max - min) / min * 100;
            var message = $"Test for {type} repeted {repeatTimes} times, each took {duration}. Min: {min} Max: {max} Diff: {diff} Avg: {avg}";

            _testOutput.WriteLine(message);
            Helper.SaveLog($"{nameof(WriteDtoToMemoryStream)}", message);
        }
コード例 #5
0
        public void DtoBuilder_ComplexEntityDto_Regenerated()
        {
            var code     = SampleCodeProvider.ComplexEntity;
            var metadata = EntityParser.FromString(code);

            metadata.DtoName = "ComplexEntityDTO";
            var otherEntityProp = metadata.Properties.Where(p => p.RelatedEntityName == "OtherEntity").Single();

            otherEntityProp.RelationMetadata = EntityParser.FromString(SampleCodeProvider.OtherEntity);

            var existingDtoTree = CSharpSyntaxTree.ParseText(SampleCodeProvider.ComplexEntityDto);

            var tree = DtoBuilder.BuildDto(metadata, existingDto: existingDtoTree);

            Assert.IsNotNull(tree);

            var codeText = tree.ToString();

            Assert.IsTrue(codeText.Contains("public string OtherNumber { get; set; }"));
            Assert.IsTrue(codeText.Contains("OtherNumber = p.Other != null ? p.Other.Number : default (string),"));

            Assert.IsTrue(codeText.Contains("public IEnumerable<SomethingDTO> List1 { get; set; }"));
            Assert.IsTrue(codeText.Contains("public IEnumerable<SomethingDTO> Enumerable2 { get; set; }"));
            Assert.IsTrue(codeText.Contains("public IEnumerable<SomethingDTO> Collection2 { get; set; }"));

            Assert.IsTrue(codeText.Contains("List1 = p.List1.AsQueryable().Select(this._somethingMapper.SelectorExpression),"));
            Assert.IsTrue(codeText.Contains("Enumerable2 = p.Enumerable2.AsQueryable().Select(this._somethingMapper.SelectorExpression),"));
            Assert.IsTrue(codeText.Contains("Collection2 = p.Collection2.AsQueryable().Select(this._somethingMapper.SelectorExpression),"));
        }
コード例 #6
0
        /// <summary>
        /// Refreshes the item.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>Task.</returns>
        private async Task RefreshItem(RefreshItem request)
        {
            var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager);

            var folder = item as Folder;

            try
            {
                await item.RefreshMetadata(CancellationToken.None, forceRefresh : request.Forced).ConfigureAwait(false);

                if (folder != null)
                {
                    // Collection folders don't validate their children so we'll have to simulate that here
                    var collectionFolder = folder as CollectionFolder;

                    if (collectionFolder != null)
                    {
                        await RefreshCollectionFolderChildren(request, collectionFolder).ConfigureAwait(false);
                    }
                    else
                    {
                        await folder.ValidateChildren(new Progress <double>(), CancellationToken.None, request.Recursive, request.Forced).ConfigureAwait(false);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorException("Error refreshing library", ex);
            }
        }
コード例 #7
0
        /// <summary>
        /// Gets the items.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>Task{ItemsResult}.</returns>
        private async Task <ItemsResult> GetItems(GetItems request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var items = GetItemsToSerialize(request, user);

            // Apply filters
            // Run them starting with the ones that are likely to reduce the list the most
            foreach (var filter in GetFilters(request).OrderByDescending(f => (int)f))
            {
                items = ApplyFilter(items, filter, user);
            }

            items = ApplyAdditionalFilters(request, items);

            items = ApplySearchTerm(request, items);

            items = ApplySortOrder(request, items, user);

            var itemsArray = items.ToArray();

            var pagedItems = ApplyPaging(request, itemsArray);

            var fields = GetItemFields(request).ToList();

            var dtoBuilder = new DtoBuilder(Logger, _libraryManager);

            var returnItems = await Task.WhenAll(pagedItems.Select(i => dtoBuilder.GetBaseItemDto(i, user, fields))).ConfigureAwait(false);

            return(new ItemsResult
            {
                TotalRecordCount = itemsArray.Length,
                Items = returnItems
            });
        }
コード例 #8
0
        /// <summary>
        /// Gets the similar items.
        /// </summary>
        /// <param name="userManager">The user manager.</param>
        /// <param name="itemRepository">The item repository.</param>
        /// <param name="libraryManager">The library manager.</param>
        /// <param name="userDataRepository">The user data repository.</param>
        /// <param name="logger">The logger.</param>
        /// <param name="request">The request.</param>
        /// <param name="includeInSearch">The include in search.</param>
        /// <param name="getSimilarityScore">The get similarity score.</param>
        /// <returns>ItemsResult.</returns>
        internal static ItemsResult GetSimilarItems(IUserManager userManager, IItemRepository itemRepository, ILibraryManager libraryManager, IUserDataRepository userDataRepository, ILogger logger, BaseGetSimilarItems request, Func <BaseItem, bool> includeInSearch, Func <BaseItem, BaseItem, int> getSimilarityScore)
        {
            var user = request.UserId.HasValue ? userManager.GetUserById(request.UserId.Value) : null;

            var item = string.IsNullOrEmpty(request.Id) ?
                       (request.UserId.HasValue ? user.RootFolder :
                        (Folder)libraryManager.RootFolder) : DtoBuilder.GetItemByClientId(request.Id, userManager, libraryManager, request.UserId);

            var fields = request.GetItemFields().ToList();

            var dtoBuilder = new DtoBuilder(logger, libraryManager, userDataRepository, itemRepository);

            var inputItems = user == null
                                 ? libraryManager.RootFolder.RecursiveChildren
                                 : user.RootFolder.GetRecursiveChildren(user);

            var items = GetSimilaritems(item, inputItems, includeInSearch, getSimilarityScore).ToArray();

            var result = new ItemsResult
            {
                Items = items.Take(request.Limit ?? items.Length).Select(i => dtoBuilder.GetBaseItemDto(i, fields, user)).Select(t => t.Result).ToArray(),

                TotalRecordCount = items.Length
            };

            return(result);
        }
コード例 #9
0
        public void ToPizzaTemplateDto_NameIsNull_PizzaTemplateDtoIsEqualToPizzaTemplate()
        {
            PizzaTemplate expected = new PizzaTemplate(
                Guid.NewGuid(),
                null,
                "ImageUrl.png",
                700);

            expected.Ingredients.Add(new Ingredient(
                                         Guid.NewGuid(),
                                         "Dough",
                                         200,
                                         "Dough.png",
                                         "DoughBase.png",
                                         Categories.Dough,
                                         5));
            expected.Ingredients.Add(new Ingredient(
                                         Guid.NewGuid(),
                                         "Bacon",
                                         200,
                                         "Bacon.png",
                                         "BaconBase.png",
                                         Categories.Meat,
                                         50));

            TemplateDto actual = DtoBuilder.ToDto(expected);

            base.AssertPizzaTemplatesAreEqual(expected, actual);
        }
コード例 #10
0
ファイル: EntityScaffolding.cs プロジェクト: p3s/craftsman
        public static void ScaffoldEntities(string srcDirectory,
                                            string testDirectory,
                                            string projectBaseName,
                                            List <Entity> entities,
                                            string dbContextName,
                                            bool addSwaggerComments,
                                            IFileSystem fileSystem)
        {
            foreach (var entity in entities)
            {
                // not worrying about DTOs, profiles, validators, fakers - they are all added by default
                EntityBuilder.CreateEntity(srcDirectory, entity, projectBaseName, fileSystem);
                DtoBuilder.CreateDtos(srcDirectory, entity, projectBaseName);
                ValidatorBuilder.CreateValidators(srcDirectory, projectBaseName, entity);
                ProfileBuilder.CreateProfile(srcDirectory, entity, projectBaseName);
                ApiRouteModifier.AddRoutes(testDirectory, entity, projectBaseName); // api routes always added to testing by default. too much of a pain to scaffold

                if (entity.Features.Count > 0)
                {
                    ControllerBuilder.CreateController(srcDirectory, entity.Name, entity.Plural, projectBaseName);
                }

                // TODO refactor to factory?
                foreach (var feature in entity.Features)
                {
                    AddFeatureToProject(srcDirectory, testDirectory, projectBaseName, dbContextName, addSwaggerComments, feature.Policies, feature, entity, fileSystem);
                }

                // Shared Tests
                FakesBuilder.CreateFakes(testDirectory, projectBaseName, entity);
            }
        }
コード例 #11
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetAdditionalParts request)
        {
            var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;

            var item = string.IsNullOrEmpty(request.Id)
                           ? (request.UserId.HasValue
                                  ? user.RootFolder
                                  : (Folder)_libraryManager.RootFolder)
                           : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, request.UserId);

            // Get everything
            var fields = Enum.GetNames(typeof(ItemFields))
                         .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
                         .ToList();

            var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);

            var video = (Video)item;

            var items = video.AdditionalPartIds.Select(_itemRepo.RetrieveItem)
                        .OrderBy(i => i.SortName)
                        .Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, video))
                        .Select(t => t.Result)
                        .ToArray();

            var result = new ItemsResult
            {
                Items            = items,
                TotalRecordCount = items.Length
            };

            return(ToOptimizedResult(result));
        }
コード例 #12
0
        public void DtoBuilder_SimpleEntity_PropertiesAdded()
        {
            var code     = SampleCodeProvider.EntityOnlySimpleProperties;
            var metadata = EntityParser.FromString(code);

            metadata.DtoName = "EntityOnlySimplePropertiesDTO";

            var tree = DtoBuilder.BuildDto(metadata, dtoNamespace: "Test.Namespace.Extra.Long");

            Assert.IsNotNull(tree);

            var codeText = tree.ToString();

            foreach (var prop in metadata.Properties.ToList())
            {
                Assert.IsTrue(codeText.Contains($"public {prop.Type} {prop.Name} {{ get; set; }}"));

                if (prop != metadata.Properties.Last())
                {
                    Assert.IsTrue(codeText.Contains($"{prop.Name} = p.{prop.Name},"));
                }
                else
                {
                    Assert.IsTrue(codeText.Contains($"{prop.Name} = p.{prop.Name}"));
                }

                Assert.IsFalse(codeText.Contains($",{prop.Name} = p.{prop.Name}"));

                Assert.IsTrue(codeText.Contains($"model.{prop.Name} = dto.{prop.Name};"));
            }

            Assert.IsTrue(codeText.Contains("using DtoGenerator.Tests.CodeSamples;"));
        }
コード例 #13
0
        public void ToPizzaItemDto_PizzaItemIsCorrect_PizzaItemDtoIsEqualToPizzaItem()
        {
            PizzaItem expected = new PizzaItem(
                Guid.NewGuid(),
                "Margarita",
                1200,
                "Margarita.png");

            expected.Order = new Order(Guid.NewGuid(), 1200, new Contact());

            expected.AddIngredient(new Ingredient(
                                       Guid.NewGuid(),
                                       "Dough",
                                       200,
                                       "Dough.png",
                                       "DoughBase.png",
                                       Categories.Dough,
                                       5));
            expected.AddIngredient(new Ingredient(
                                       Guid.NewGuid(),
                                       "Bacon",
                                       200,
                                       "Bacon.png",
                                       "BaconBase.png",
                                       Categories.Meat,
                                       500));


            PizzaItemDto actual = DtoBuilder.ToDto(expected);


            base.AssertPizzaItemsAreEqual(expected, actual);
        }
コード例 #14
0
        private async Task <ThemeMediaResult> GetThemeSongs(GetThemeSongs request)
        {
            var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;

            var item = string.IsNullOrEmpty(request.Id)
                           ? (request.UserId.HasValue
                                  ? user.RootFolder
                                  : (Folder)_libraryManager.RootFolder)
                           : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, request.UserId);

            while (item.ThemeSongIds.Count == 0 && request.InheritFromParent && item.Parent != null)
            {
                item = item.Parent;
            }

            // Get everything
            var fields = Enum.GetNames(typeof(ItemFields))
                         .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
                         .ToList();

            var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);

            var tasks = item.ThemeSongIds.Select(_itemRepo.RetrieveItem)
                        .OrderBy(i => i.SortName)
                        .Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, item));

            var items = await Task.WhenAll(tasks).ConfigureAwait(false);

            return(new ThemeMediaResult
            {
                Items = items,
                TotalRecordCount = items.Length,
                OwnerId = DtoBuilder.GetClientItemId(item)
            });
        }
コード例 #15
0
        private static void RunEntityBuilders(string solutionDirectory, ApiTemplate template, IFileSystem fileSystem)
        {
            //entities
            foreach (var entity in template.Entities)
            {
                EntityBuilder.CreateEntity(solutionDirectory, entity, fileSystem);
                DtoBuilder.CreateDtos(solutionDirectory, entity);

                RepositoryBuilder.AddRepository(solutionDirectory, entity, template.DbContext);
                ValidatorBuilder.CreateValidators(solutionDirectory, entity);
                ProfileBuilder.CreateProfile(solutionDirectory, entity);

                ControllerBuilder.CreateController(solutionDirectory, entity, template.SwaggerConfig.AddSwaggerComments);

                FakesBuilder.CreateFakes(solutionDirectory, template, entity);
                ReadTestBuilder.CreateEntityReadTests(solutionDirectory, template, entity);
                GetTestBuilder.CreateEntityGetTests(solutionDirectory, template, entity);
                PostTestBuilder.CreateEntityWriteTests(solutionDirectory, template, entity);
                UpdateTestBuilder.CreateEntityUpdateTests(solutionDirectory, template, entity);
                DeleteTestBuilder.DeleteEntityWriteTests(solutionDirectory, template, entity);
            }

            //seeders & dbsets
            SeederModifier.AddSeeders(solutionDirectory, template);
            DbContextModifier.AddDbSet(solutionDirectory, template);
        }
コード例 #16
0
        public static void ScaffoldEntities(string solutionDirectory,
                                            string srcDirectory,
                                            string testDirectory,
                                            string projectBaseName,
                                            List <Entity> entities,
                                            string dbContextName,
                                            bool addSwaggerComments,
                                            bool useSoftDelete,
                                            IFileSystem fileSystem)
        {
            foreach (var entity in entities)
            {
                // not worrying about DTOs, profiles, validators, fakers - they are all added by default
                EntityBuilder.CreateEntity(solutionDirectory, srcDirectory, entity, projectBaseName, fileSystem);
                DtoBuilder.CreateDtos(solutionDirectory, entity, projectBaseName);
                ValidatorBuilder.CreateValidators(solutionDirectory, srcDirectory, projectBaseName, entity);
                ProfileBuilder.CreateProfile(srcDirectory, entity, projectBaseName);
                ApiRouteModifier.AddRoutes(testDirectory, entity, projectBaseName); // api routes always added to testing by default. too much of a pain to scaffold dynamically

                var isProtected = entity.Features.Any(f => f.IsProtected);          // <-- one more example of why it would be nice to have specific endpoints for each feature 😤
                if (entity.Features.Count > 0)
                {
                    ControllerBuilder.CreateController(solutionDirectory, srcDirectory, entity.Name, entity.Plural, projectBaseName, isProtected, fileSystem);
                }

                // TODO refactor to factory?
                foreach (var feature in entity.Features)
                {
                    AddFeatureToProject(solutionDirectory, srcDirectory, testDirectory, projectBaseName, dbContextName, addSwaggerComments, feature, entity, useSoftDelete, fileSystem);
                }

                // Shared Tests
                FakesBuilder.CreateFakes(solutionDirectory, testDirectory, projectBaseName, entity, fileSystem);
            }
        }
コード例 #17
0
        public void ToContactDto_ContactWithEmptyFields_ContactDtoIsEqualToContact()
        {
            Contact contact = new Contact();

            ContactDto result = DtoBuilder.ToDto(contact);

            base.AssertContactsAreEqual(contact, result);
        }
コード例 #18
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetItemImageInfos request)
        {
            var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager);

            var result = GetItemImageInfos(item).Result;

            return ToOptimizedResult(result);
        }
コード例 #19
0
        public void ToIngredientDto_IngredientWithEmptyFields_IngredientDtoIsEqualToIngredient()
        {
            Ingredient ingredient = new Ingredient();

            IngredientDto result = DtoBuilder.ToDto(ingredient);

            base.AssertIngredientsAreEqual(ingredient, result);
        }
コード例 #20
0
        private Task UpdateItem(UpdateItem request)
        {
            var item = DtoBuilder.GetItemByClientId(request.ItemId, _userManager, _libraryManager);

            UpdateItem(request, item);

            return(_libraryManager.UpdateItem(item, ItemUpdateType.MetadataEdit, CancellationToken.None));
        }
コード例 #21
0
        public void Create_ClassWithLists_InstanceFilled()
        {
            var builder = new DtoBuilder();
            var ins     = builder.Create <ClassWith256Lists <int> >();

            Assert.NotNull(ins);
            Assert.True(IsInstanceWithArrysValid <ClassWith256Lists <int>, int>(ins, IsIntValid));
        }
コード例 #22
0
        public void ToUserDto_OrdersAreEmpty_UserDtoIsEqualToUser()
        {
            User user = new User("Name", "Email");

            UserDto userDto = DtoBuilder.ToDto(user);

            base.AssertUsersAreEqual(user, userDto);
        }
コード例 #23
0
        /// <summary>
        /// Updates the played status.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="itemId">The item id.</param>
        /// <param name="wasPlayed">if set to <c>true</c> [was played].</param>
        /// <returns>Task.</returns>
        private async Task <UserItemDataDto> UpdatePlayedStatus(User user, string itemId, bool wasPlayed)
        {
            var item = DtoBuilder.GetItemByClientId(itemId, _userManager, _libraryManager, user.Id);

            await item.SetPlayedStatus(user, wasPlayed, _userDataRepository).ConfigureAwait(false);

            return(DtoBuilder.GetUserItemDataDto(_userDataRepository.GetUserData(user.Id, item.GetUserDataKey())));
        }
コード例 #24
0
        public void Create_ClassWithStrings_InstanceFilled()
        {
            var builder = new DtoBuilder();
            var ins     = builder.Create <ClassWith256Strings>();

            Assert.NotNull(ins);
            Assert.True(IsInstanceValid <ClassWith256Strings, string>(ins, IsStringValid));
        }
コード例 #25
0
        public void ToCategoryDto_CategoryIsDough_NameIsEqualToDoughCategoryName()
        {
            Categories doughCategory = Categories.Dough;

            CategoryDto result = DtoBuilder.ToDto(doughCategory);

            Assert.AreEqual(doughCategory.ToString(), result.Name);
        }
コード例 #26
0
        public void Create_ClassWithInts_InstanceFilled()
        {
            var builder = new DtoBuilder();
            var ins     = builder.Create <ClassWith256Ints>();

            Assert.NotNull(ins);
            Assert.True(IsInstanceValid <ClassWith256Ints, int>(ins, IsIntValid));
        }
コード例 #27
0
        /// <summary>
        /// Updates the now playing item id.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="clientType">Type of the client.</param>
        /// <param name="deviceId">The device id.</param>
        /// <param name="deviceName">Name of the device.</param>
        /// <param name="item">The item.</param>
        /// <param name="currentPositionTicks">The current position ticks.</param>
        private void UpdateNowPlayingItemId(User user, string clientType, string deviceId, string deviceName, BaseItem item, long?currentPositionTicks = null)
        {
            var conn = GetConnection(user.Id, clientType, deviceId, deviceName);

            conn.NowPlayingPositionTicks = currentPositionTicks;
            conn.NowPlayingItem          = DtoBuilder.GetBaseItemInfo(item);
            conn.LastActivityDate        = DateTime.UtcNow;
        }
コード例 #28
0
        public void ToCategoryDto_CategoryIsCheese_NameIsEqualToCheeseCategoryName()
        {
            Categories cheeseCategory = Categories.Cheese;

            CategoryDto result = DtoBuilder.ToDto(cheeseCategory);

            Assert.AreEqual(cheeseCategory.ToString(), result.Name);
        }
コード例 #29
0
        /// <summary>
        /// Posts the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        public void Post(OnPlaybackStart request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);

            _sessionManager.OnPlaybackStart(item, GetSession().Id);
        }
コード例 #30
0
        public void ToPizzaTemplateDto_PizzaTemplateIsEmpty_PizzaTemplateDtoIsEqualToPizzaTemplate()
        {
            PizzaTemplate expected = new PizzaTemplate();

            TemplateDto actual = DtoBuilder.ToDto(expected);

            base.AssertPizzaTemplatesAreEqual(expected, actual);
        }