< Summary

Class:BIWCompleteAction
Assembly:BuilderInWorld
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Scripts/ActionController/BIWCompleteAction.cs
Covered lines:26
Uncovered lines:0
Coverable lines:26
Total lines:63
Line coverage:100% (26 of 26)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BIWCompleteAction()0%110100%
Redo()0%220100%
IsDone()0%110100%
Undo()0%220100%
ApplyValue(...)0%220100%
CreateChangeFloorAction(...)0%110100%
CreateActionType(...)0%110100%
CreateActionType(...)0%110100%
CreateAction(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Scripts/ActionController/BIWCompleteAction.cs

#LineLine coverage
 1using DCL.Models;
 2using System.Collections;
 3using System.Collections.Generic;
 4using UnityEngine;
 5using Newtonsoft.Json;
 6
 7public class BIWCompleteAction : IBIWCompleteAction
 8{
 9
 10    public IBIWCompleteAction.ActionType actionType;
 1311    public bool isDone = true;
 12
 13    public event IBIWCompleteAction.OnApplyValueDelegate OnApplyValue;
 14
 1315    List<BIWEntityAction> entityApplied = new List<BIWEntityAction>();
 16
 17    public void Redo()
 18    {
 2419        foreach (BIWEntityAction action in entityApplied)
 20        {
 621            ApplyValue(action.entityId, action.newValue, false);
 22        }
 623        isDone = true;
 624    }
 5825    public bool IsDone() => isDone;
 26
 27    public void Undo()
 28    {
 2429        foreach (BIWEntityAction action in entityApplied)
 30        {
 631            ApplyValue(action.entityId, action.oldValue, true);
 32        }
 33
 634        isDone = false;
 35
 636    }
 37
 2438    private void ApplyValue(string entityToApply, object value, bool isUndo) { OnApplyValue?.Invoke(entityToApply, value
 39
 40    public void CreateChangeFloorAction(CatalogItem oldFloor, CatalogItem newFloor)
 41    {
 342        BIWEntityAction action = new BIWEntityAction(JsonConvert.SerializeObject(oldFloor), JsonConvert.SerializeObject(
 343        List<BIWEntityAction> list = new List<BIWEntityAction>();
 344        list.Add(action);
 345        CreateAction(list, IBIWCompleteAction.ActionType.CHANGE_FLOOR);
 346    }
 47
 48    public void CreateActionType(BIWEntityAction action, IBIWCompleteAction.ActionType type)
 49    {
 450        List<BIWEntityAction> list = new List<BIWEntityAction>();
 451        list.Add(action);
 452        CreateAction(list, type);
 453    }
 54
 1255    public void CreateActionType(List<BIWEntityAction> entitiesActions, IBIWCompleteAction.ActionType type) { CreateActi
 56
 57    void CreateAction(List<BIWEntityAction> entitiesActions, IBIWCompleteAction.ActionType type)
 58    {
 1359        actionType = type;
 1360        entityApplied = entitiesActions;
 1361        isDone = true;
 1362    }
 63}