Initial Commit
This commit is contained in:
parent
53eb92e9af
commit
270ab7d11f
15341 changed files with 700234 additions and 0 deletions
|
@ -0,0 +1,341 @@
|
|||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using NUnit.Framework;
|
||||
using Unity.Cloud.Collaborate.Models;
|
||||
using Unity.Cloud.Collaborate.Models.Structures;
|
||||
using Unity.Cloud.Collaborate.Presenters;
|
||||
using Unity.Cloud.Collaborate.Tests.Models;
|
||||
using Unity.Cloud.Collaborate.Views;
|
||||
|
||||
namespace Unity.Cloud.Collaborate.Tests.Presenters
|
||||
{
|
||||
public class ChangesPresenterTests
|
||||
{
|
||||
class TestableChangesPresenter : ChangesPresenter
|
||||
{
|
||||
public TestableChangesPresenter([NotNull] IChangesView view, [NotNull] IChangesModel model, [NotNull] IMainModel mainModel)
|
||||
: base(view, model, mainModel)
|
||||
{
|
||||
}
|
||||
|
||||
public void NotifyOnRemoteRevisionsAvailabilityChange(bool available)
|
||||
{
|
||||
base.OnRemoteRevisionsAvailabilityChange(available);
|
||||
}
|
||||
|
||||
public void NotifyOnUpdatedChangeList()
|
||||
{
|
||||
base.OnUpdatedChangeList();
|
||||
}
|
||||
|
||||
public void NotifyOnUpdatedPartiallySelectedChanges()
|
||||
{
|
||||
base.OnUpdatedPartiallySelectedChanges();
|
||||
}
|
||||
|
||||
public void NotifyOnConflictStatusChange(bool conflicted)
|
||||
{
|
||||
base.OnConflictStatusChange(conflicted);
|
||||
}
|
||||
}
|
||||
TestChangesView m_View;
|
||||
TestChangesModel m_Model;
|
||||
TestMainModel m_MainModel;
|
||||
TestableChangesPresenter m_Presenter;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
m_View = new TestChangesView();
|
||||
m_Model = new TestChangesModel();
|
||||
m_MainModel = new TestMainModel();
|
||||
m_Presenter = new TestableChangesPresenter(m_View, m_Model, m_MainModel);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
m_Presenter.Stop();
|
||||
m_View = null;
|
||||
m_Model = null;
|
||||
m_MainModel = null;
|
||||
m_Presenter = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestToggledCountValue()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
m_Model.ToggledEntries = new List<IChangeEntryData>
|
||||
{
|
||||
new TestChangesModel.ChangeEntryData { Toggled = true, Entry = new ChangeEntry("path") },
|
||||
new TestChangesModel.ChangeEntryData { Toggled = true, Entry = new ChangeEntry("path2") }
|
||||
};
|
||||
Assert.AreEqual(2, m_Presenter.ToggledCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTotalCountValue()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
m_Model.AllEntries = new List<IChangeEntryData>
|
||||
{
|
||||
new TestChangesModel.ChangeEntryData { Toggled = true, Entry = new ChangeEntry("path") },
|
||||
new TestChangesModel.ChangeEntryData { Toggled = false, Entry = new ChangeEntry("path2") }
|
||||
};
|
||||
Assert.AreEqual(2, m_Presenter.TotalCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestConflictedCountValue()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
m_Model.ConflictedEntries = new List<IChangeEntryData>
|
||||
{
|
||||
new TestChangesModel.ChangeEntryData
|
||||
{
|
||||
Conflicted = true,
|
||||
Entry = new ChangeEntry("path", null, ChangeEntryStatus.Unmerged, false, true)
|
||||
},
|
||||
new TestChangesModel.ChangeEntryData
|
||||
{
|
||||
Conflicted = true,
|
||||
Entry = new ChangeEntry("path2", null, ChangeEntryStatus.Unmerged, false, true)
|
||||
}
|
||||
};
|
||||
Assert.AreEqual(2, m_Presenter.ConflictedCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSearchingValue()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
m_Model.SavedSearchQuery = "test";
|
||||
Assert.IsTrue(m_Presenter.Searching);
|
||||
m_Model.SavedSearchQuery = "";
|
||||
Assert.IsFalse(m_Presenter.Searching);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSettingEntryToggle()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
const string path = "path";
|
||||
const bool value = true;
|
||||
m_Presenter.UpdateEntryToggle(path, value);
|
||||
Assert.AreEqual(1, m_Model.UpdateEntryToggleCount);
|
||||
Assert.AreEqual(path, m_Model.UpdateEntryTogglePath);
|
||||
Assert.AreEqual(value, m_Model.UpdateEntryToggleValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRequestPublish()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
m_Model.SavedSearchQuery = "";
|
||||
m_Model.ToggledEntries = new List<IChangeEntryData>
|
||||
{
|
||||
new TestChangesModel.ChangeEntryData { Toggled = true, Entry = new ChangeEntry("path") }
|
||||
};
|
||||
m_Presenter.RequestPublish();
|
||||
Assert.AreEqual(1, m_Model.GetToggledEntriesCount);
|
||||
Assert.AreEqual(1, m_Model.RequestPublishCount);
|
||||
Assert.AreEqual(1, m_Model.RequestPublishList.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRequestPublishFailWhenSearching()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
m_Model.SavedSearchQuery = "some query";
|
||||
Assert.Catch(() => m_Presenter.RequestPublish());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRequestDiscard()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
const string path = "path";
|
||||
var entry = new ChangeEntry(path);
|
||||
m_Presenter.RequestDiscard(entry);
|
||||
Assert.AreEqual(1, m_Model.RequestDiscardCount);
|
||||
Assert.AreEqual(path, m_Model.RequestDiscardEntry.Path);
|
||||
// Ensure it created a dialogue
|
||||
Assert.AreEqual(1, m_View.DisplayDialogueCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRequestDiffChanges()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
const string path = "path";
|
||||
m_Presenter.RequestDiffChanges(path);
|
||||
Assert.AreEqual(1, m_Model.RequestDiffCount);
|
||||
Assert.AreEqual(path, m_Model.RequestDiffPath);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSetSearchQuery()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
Assert.AreEqual(1, m_View.SetSearchQueryCount);
|
||||
const string query = "path Path ";
|
||||
m_Presenter.SetSearchQuery(query);
|
||||
Assert.AreEqual(query.Trim().ToLower(), m_Model.SavedSearchQuery);
|
||||
Assert.AreEqual(2, m_View.SetSearchQueryCount);
|
||||
Assert.AreEqual(query, m_View.SetSearchQueryValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHavingSearchQueryDisablesPublish()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
m_Model.ToggledEntries = new List<IChangeEntryData>
|
||||
{
|
||||
new TestChangesModel.ChangeEntryData { Toggled = true, Entry = new ChangeEntry("path") }
|
||||
};
|
||||
// Base case
|
||||
m_Presenter.SetSearchQuery("");
|
||||
Assert.AreEqual(1, m_View.SetPublishEnabledCount);
|
||||
Assert.AreEqual(true, m_View.SetPublishEnabledValue);
|
||||
// Base to disabled case
|
||||
m_Presenter.SetSearchQuery("query");
|
||||
Assert.AreEqual(2, m_View.SetPublishEnabledCount);
|
||||
Assert.AreEqual(false, m_View.SetPublishEnabledValue);
|
||||
Assert.IsNotNull(m_View.SetPublishEnabledReason);
|
||||
// Disabled back to base case.
|
||||
m_Presenter.SetSearchQuery("");
|
||||
Assert.AreEqual(3, m_View.SetPublishEnabledCount);
|
||||
Assert.AreEqual(true, m_View.SetPublishEnabledValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHavingConflictsDisablesPublish()
|
||||
{
|
||||
m_Model.ToggledEntries = new List<IChangeEntryData>()
|
||||
{
|
||||
new TestChangesModel.ChangeEntryData
|
||||
{
|
||||
Entry = new ChangeEntry("path", null, ChangeEntryStatus.Modified)
|
||||
}
|
||||
};
|
||||
// Base case
|
||||
m_Presenter.Start();
|
||||
m_Model.ConflictedEntries = new List<IChangeEntryData>();
|
||||
m_Model.TriggerUpdatedChangeList();
|
||||
Assert.AreEqual(1, m_View.SetPublishEnabledCount);
|
||||
Assert.AreEqual(true, m_View.SetPublishEnabledValue);
|
||||
|
||||
// Disable
|
||||
m_Model.ConflictedEntries = new List<IChangeEntryData>
|
||||
{
|
||||
new TestChangesModel.ChangeEntryData
|
||||
{
|
||||
Conflicted = true,
|
||||
Entry = new ChangeEntry("path", null, ChangeEntryStatus.Unmerged, false, true)
|
||||
}
|
||||
};
|
||||
m_Model.TriggerUpdatedChangeList();
|
||||
Assert.AreEqual(2, m_View.SetPublishEnabledCount);
|
||||
Assert.AreEqual(false, m_View.SetPublishEnabledValue);
|
||||
Assert.IsNotNull(m_View.SetPublishEnabledReason);
|
||||
|
||||
// Re enabled
|
||||
m_Model.ConflictedEntries = new List<IChangeEntryData>();
|
||||
m_Model.TriggerUpdatedChangeList();
|
||||
Assert.AreEqual(3, m_View.SetPublishEnabledCount);
|
||||
Assert.AreEqual(true, m_View.SetPublishEnabledValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSetRevisionService()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
Assert.AreEqual(1, m_View.SetRevisionSummaryCount);
|
||||
const string summary = "summary";
|
||||
m_Presenter.SetRevisionSummary(summary);
|
||||
Assert.AreEqual(summary, m_Model.SavedRevisionSummary);
|
||||
Assert.AreEqual(2, m_View.SetRevisionSummaryCount);
|
||||
Assert.AreEqual(summary, m_View.SetRevisionSummaryValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestReceivingBusyMessage()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
// Sent initial status on start
|
||||
Assert.AreEqual(1, m_View.SetBusyStatusCount);
|
||||
Assert.AreEqual(false, m_View.SetBusyStatusValue);
|
||||
|
||||
// Test values once events called:
|
||||
m_Model.TriggerBusyStatusUpdated(true);
|
||||
Assert.AreEqual(2, m_View.SetBusyStatusCount);
|
||||
Assert.AreEqual(true, m_View.SetBusyStatusValue);
|
||||
|
||||
m_Model.TriggerBusyStatusUpdated(false);
|
||||
Assert.AreEqual(3, m_View.SetBusyStatusCount);
|
||||
Assert.AreEqual(false, m_View.SetBusyStatusValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOnUpdatedChangeListUpdatesPublishButton()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
m_Model.ToggledEntries = new List<IChangeEntryData>
|
||||
{
|
||||
new TestChangesModel.ChangeEntryData { Toggled = true, Entry = new ChangeEntry("path") },
|
||||
new TestChangesModel.ChangeEntryData { Toggled = false, Entry = new ChangeEntry("path2") }
|
||||
};
|
||||
m_Presenter.NotifyOnUpdatedChangeList();
|
||||
Assert.AreEqual(true, m_View.SetPublishEnabledValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOnPartialChangesUpdatesPublishButton()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
m_Model.ToggledEntries = new List<IChangeEntryData>
|
||||
{
|
||||
new TestChangesModel.ChangeEntryData { Toggled = true, Entry = new ChangeEntry("path") },
|
||||
new TestChangesModel.ChangeEntryData { Toggled = false, Entry = new ChangeEntry("path2") }
|
||||
};
|
||||
m_Presenter.NotifyOnUpdatedPartiallySelectedChanges();
|
||||
Assert.AreEqual(true, m_View.SetPublishEnabledValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOnRemoteRevisionsAvailabilityChangeUpdatesPublishButton()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
m_Model.ToggledEntries = new List<IChangeEntryData>
|
||||
{
|
||||
new TestChangesModel.ChangeEntryData { Toggled = true, Entry = new ChangeEntry("path") },
|
||||
new TestChangesModel.ChangeEntryData { Toggled = false, Entry = new ChangeEntry("path2") }
|
||||
};
|
||||
m_MainModel.RemoteRevisionsAvailable = true;
|
||||
m_Presenter.NotifyOnRemoteRevisionsAvailabilityChange(true);
|
||||
Assert.AreEqual(false, m_View.SetPublishEnabledValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOnConflictStatusChangeUpdatesPublishButton()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
m_Model.ToggledEntries = new List<IChangeEntryData>
|
||||
{
|
||||
new TestChangesModel.ChangeEntryData { Toggled = true, Entry = new ChangeEntry("path") },
|
||||
new TestChangesModel.ChangeEntryData { Toggled = false, Entry = new ChangeEntry("path2") }
|
||||
};
|
||||
m_Model.ConflictedEntries = new List<IChangeEntryData>
|
||||
{
|
||||
new TestChangesModel.ChangeEntryData
|
||||
{
|
||||
Conflicted = true,
|
||||
Entry = new ChangeEntry("path", null, ChangeEntryStatus.Unmerged, false, true)
|
||||
}
|
||||
};
|
||||
m_Presenter.NotifyOnConflictStatusChange(true);
|
||||
Assert.AreEqual(false, m_View.SetPublishEnabledValue);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 27c4708da6102f346a800846ab2a1e47
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,190 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using Unity.Cloud.Collaborate.Models.Structures;
|
||||
using Unity.Cloud.Collaborate.Presenters;
|
||||
using Unity.Cloud.Collaborate.Tests.Models;
|
||||
|
||||
namespace Unity.Cloud.Collaborate.Tests.Presenters
|
||||
{
|
||||
public class HistoryPresenterTests
|
||||
{
|
||||
TestHistoryView m_View;
|
||||
TestHistoryModel m_HistoryModel;
|
||||
TestMainModel m_MainModel;
|
||||
HistoryPresenter m_Presenter;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
m_View = new TestHistoryView();
|
||||
m_HistoryModel = new TestHistoryModel();
|
||||
m_MainModel = new TestMainModel();
|
||||
m_Presenter = new HistoryPresenter(m_View, m_HistoryModel, m_MainModel);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
m_Presenter.Stop();
|
||||
m_View = null;
|
||||
m_HistoryModel = null;
|
||||
m_Presenter = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStartCall()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
|
||||
// Clear box testing here
|
||||
Assert.AreEqual(m_HistoryModel.Busy, m_View.BusyStatus);
|
||||
Assert.AreEqual(1, m_HistoryModel.RequestedEntryCountCount);
|
||||
Assert.AreEqual(1, m_HistoryModel.RequestedPageOfRevisionsCount);
|
||||
Assert.AreEqual(0, m_HistoryModel.RequestedSingleRevisionCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStartWithSavedRevisionCall()
|
||||
{
|
||||
const string savedRevisionId = "123";
|
||||
|
||||
m_HistoryModel.SavedRevisionId = savedRevisionId;
|
||||
m_Presenter.Start();
|
||||
|
||||
// Clear box testing here
|
||||
Assert.AreEqual(m_HistoryModel.Busy, m_View.BusyStatus);
|
||||
Assert.AreEqual(1, m_HistoryModel.RequestedEntryCountCount);
|
||||
Assert.AreEqual(0, m_HistoryModel.RequestedPageOfRevisionsCount);
|
||||
Assert.AreEqual(1, m_HistoryModel.RequestedSingleRevisionCount);
|
||||
Assert.AreEqual(savedRevisionId, m_HistoryModel.RequestedRevisionId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestReceivingUpdateEvent()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
|
||||
// Clear box testing here
|
||||
m_HistoryModel.TriggerUpdatedEntryListEvent();
|
||||
Assert.AreEqual(2, m_HistoryModel.RequestedEntryCountCount);
|
||||
Assert.AreEqual(2, m_HistoryModel.RequestedPageOfRevisionsCount);
|
||||
Assert.AreEqual(0, m_HistoryModel.RequestedSingleRevisionCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestReceivingUpdateEventWithSelection()
|
||||
{
|
||||
const string selectedRevisionId = "123";
|
||||
|
||||
m_HistoryModel.SelectedRevisionId = selectedRevisionId;
|
||||
m_Presenter.Start();
|
||||
|
||||
// Clear box testing here
|
||||
m_HistoryModel.TriggerUpdatedEntryListEvent();
|
||||
Assert.AreEqual(2, m_HistoryModel.RequestedEntryCountCount);
|
||||
Assert.AreEqual(2, m_HistoryModel.RequestedSingleRevisionCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestReceivingEntryCount()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
|
||||
m_HistoryModel.PageNumber = 1;
|
||||
m_HistoryModel.SetNumberOfEntries(HistoryPresenter.pageSize * 2 + 1);
|
||||
Assert.AreEqual(2, m_View.MaxPage);
|
||||
Assert.AreEqual(1, m_View.Page);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPreviousPageCall()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
|
||||
m_HistoryModel.PageNumber = 1;
|
||||
m_Presenter.PrevPage();
|
||||
Assert.AreEqual(HistoryPresenter.pageSize, m_HistoryModel.RequestedPageSize, "Page size should match given value");
|
||||
Assert.AreEqual(0, m_HistoryModel.PageNumber, "Requesting previous page should request previous page.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPreviousPageCallOnZero()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
|
||||
m_HistoryModel.PageNumber = 0;
|
||||
m_Presenter.PrevPage();
|
||||
Assert.AreEqual(HistoryPresenter.pageSize, m_HistoryModel.RequestedPageSize, "Page size should match given value");
|
||||
Assert.AreEqual(0, m_HistoryModel.PageNumber, "Requesting previous page on page zero shouldn't stay at zero.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNextPageCall()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
|
||||
m_HistoryModel.PageNumber = 0;
|
||||
m_HistoryModel.SetNumberOfEntries(HistoryPresenter.pageSize * 2);
|
||||
m_Presenter.NextPage();
|
||||
Assert.AreEqual(HistoryPresenter.pageSize, m_HistoryModel.RequestedPageSize, "Page size should match given value");
|
||||
Assert.AreEqual(1, m_HistoryModel.PageNumber, "Requesting previous page should request next page.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNextPageCallOnZero()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
|
||||
m_HistoryModel.PageNumber = 1;
|
||||
m_HistoryModel.SetNumberOfEntries(HistoryPresenter.pageSize * 2);
|
||||
m_Presenter.NextPage();
|
||||
Assert.AreEqual(HistoryPresenter.pageSize, m_HistoryModel.RequestedPageSize, "Page size should match given value");
|
||||
Assert.AreEqual(1, m_HistoryModel.PageNumber, "Requesting next page on max page should not change the page.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSetSelectedRevisionId()
|
||||
{
|
||||
const string selectedRevisionId = "123";
|
||||
m_Presenter.Start();
|
||||
|
||||
m_Presenter.SelectedRevisionId = selectedRevisionId;
|
||||
Assert.AreEqual(selectedRevisionId, m_HistoryModel.RequestedRevisionId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGotoCall()
|
||||
{
|
||||
const string revisionId = "123";
|
||||
m_Presenter.Start();
|
||||
|
||||
var status = HistoryEntryStatus.Ahead;
|
||||
m_Presenter.RequestGoto(revisionId, status);
|
||||
Assert.AreEqual(1, m_HistoryModel.RequestedUpdateToCount);
|
||||
Assert.AreEqual(revisionId, m_HistoryModel.RequestedUpdateToRevisionId);
|
||||
|
||||
status = HistoryEntryStatus.Current;
|
||||
m_Presenter.RequestGoto(revisionId, status);
|
||||
Assert.AreEqual(1, m_HistoryModel.RequestedRestoreToCount);
|
||||
Assert.AreEqual(revisionId, m_HistoryModel.RequestedRestoreToRevisionId);
|
||||
|
||||
status = HistoryEntryStatus.Behind;
|
||||
m_Presenter.RequestGoto(revisionId, status);
|
||||
Assert.AreEqual(1, m_HistoryModel.RequestedGoBackToCount);
|
||||
Assert.AreEqual(revisionId, m_HistoryModel.RequestedGoBackToRevisionId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRevertCall()
|
||||
{
|
||||
const string revisionId = "123";
|
||||
m_Presenter.Start();
|
||||
|
||||
m_Presenter.RequestRevert(revisionId, new List<string> { "a", "b", "c" });
|
||||
Assert.AreEqual(1, m_HistoryModel.RequestedRevertCount);
|
||||
Assert.AreEqual(revisionId, m_HistoryModel.RequestedRevertRevisionId);
|
||||
Assert.AreEqual(3, m_HistoryModel.RequestedRevertFileCount);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9f5d8073410f83d479361cd2b45bcf60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,128 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Unity.Cloud.Collaborate.Models.Structures;
|
||||
using Unity.Cloud.Collaborate.Presenters;
|
||||
using Unity.Cloud.Collaborate.Tests.Models;
|
||||
|
||||
namespace Unity.Cloud.Collaborate.Tests.Presenters
|
||||
{
|
||||
public class MainPresenterTests
|
||||
{
|
||||
TestMainView m_View;
|
||||
TestMainModel m_MainModel;
|
||||
MainPresenter m_Presenter;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
m_View = new TestMainView();
|
||||
m_MainModel = new TestMainModel();
|
||||
m_Presenter = new MainPresenter(m_View, m_MainModel);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
m_Presenter.Stop();
|
||||
m_View = null;
|
||||
m_MainModel = null;
|
||||
m_Presenter = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBackNavigation()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
|
||||
var called = false;
|
||||
m_MainModel.backNavigation = ("test", "test-text", () => called = true);
|
||||
m_Presenter.NavigateBack();
|
||||
|
||||
Assert.IsTrue(called);
|
||||
Assert.IsNull(m_MainModel.backNavigation);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBackNavigationWithNull()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
|
||||
m_MainModel.backNavigation = null;
|
||||
m_Presenter.NavigateBack();
|
||||
|
||||
Assert.IsNull(m_MainModel.backNavigation);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAssigningPresenters()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
|
||||
var changesView = new TestChangesView();
|
||||
m_Presenter.AssignChangesPresenter(changesView);
|
||||
Assert.IsNotNull(changesView.Presenter);
|
||||
|
||||
var historyView = new TestHistoryView();
|
||||
m_Presenter.AssignHistoryPresenter(historyView);
|
||||
Assert.IsNotNull(historyView.Presenter);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCancellingJob()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
|
||||
m_Presenter.RequestCancelJob();
|
||||
|
||||
Assert.AreEqual(1, m_MainModel.requestCancelJobCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSettingTabIndex()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
|
||||
const int newVal = 5;
|
||||
m_Presenter.UpdateTabIndex(newVal);
|
||||
|
||||
Assert.AreEqual(newVal, m_MainModel.CurrentTabIndex);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStartingWithJobInProgress()
|
||||
{
|
||||
m_MainModel.ProgressInfo = new ProgressInfo("test", "test", 50, 20);
|
||||
m_Presenter.Start();
|
||||
|
||||
Assert.IsTrue(m_View.inProgress);
|
||||
Assert.IsNotNull(m_View.progress);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStartingWithError()
|
||||
{
|
||||
const string message = "test message";
|
||||
m_MainModel.ErrorInfo = new ErrorInfo(20, 1, (int)ErrorInfoBehavior.Alert, message, "test", "20");
|
||||
m_Presenter.Start();
|
||||
|
||||
Assert.AreEqual(1, m_View.alerts.Count);
|
||||
Assert.AreEqual(message, m_View.alerts.First().Value.message);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestReceivingStateChange()
|
||||
{
|
||||
const string message = "test message";
|
||||
const int tabIndex = 67;
|
||||
|
||||
m_Presenter.Start();
|
||||
m_MainModel.backNavigation = ("id", message, () => { });
|
||||
m_MainModel.CurrentTabIndex = tabIndex;
|
||||
m_MainModel.TriggerStateChanged();
|
||||
|
||||
Assert.AreEqual(message, m_View.backNavigation);
|
||||
Assert.AreEqual(tabIndex, m_View.tabIndex);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c27224849b8648b991691de4f0c90456
|
||||
timeCreated: 1576178835
|
|
@ -0,0 +1,94 @@
|
|||
using NUnit.Framework;
|
||||
using Unity.Cloud.Collaborate.Models.Enums;
|
||||
using Unity.Cloud.Collaborate.Presenters;
|
||||
using Unity.Cloud.Collaborate.Tests.Models;
|
||||
|
||||
namespace Unity.Cloud.Collaborate.Tests.Presenters
|
||||
{
|
||||
internal class StartPresenterTests
|
||||
{
|
||||
TestStartView m_View;
|
||||
TestStartModel m_Model;
|
||||
StartPresenter m_Presenter;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
m_View = new TestStartView();
|
||||
m_Model = new TestStartModel();;
|
||||
m_Presenter = new StartPresenter(m_View, m_Model);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
m_Presenter.Stop();
|
||||
m_View = null;
|
||||
m_Model = null;
|
||||
m_Presenter = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRequestingStart()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
|
||||
m_Model.ProjectStatus = ProjectStatus.Bound;
|
||||
m_Presenter.RequestStart();
|
||||
Assert.AreEqual(1, m_Model.requestTurnOnServiceCount);
|
||||
|
||||
m_Model.ProjectStatus = ProjectStatus.Unbound;
|
||||
m_Presenter.RequestStart();
|
||||
Assert.AreEqual(1, m_Model.showServicePageCount);
|
||||
|
||||
m_Model.ProjectStatus = ProjectStatus.LoggedOut;
|
||||
m_Presenter.RequestStart();
|
||||
Assert.AreEqual(1, m_Model.showLoginPageCount);
|
||||
|
||||
m_Model.ProjectStatus = ProjectStatus.NoSeat;
|
||||
m_Presenter.RequestStart();
|
||||
Assert.AreEqual(1, m_Model.showNoSeatPageCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUpdatingProjectStatus()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
|
||||
m_Model.TriggerProjectStatusChanged(ProjectStatus.Bound);
|
||||
Assert.IsTrue(m_View.buttonVisible);
|
||||
|
||||
m_Model.TriggerProjectStatusChanged(ProjectStatus.Unbound);
|
||||
Assert.IsTrue(m_View.buttonVisible);
|
||||
|
||||
m_Model.TriggerProjectStatusChanged(ProjectStatus.LoggedOut);
|
||||
Assert.IsTrue(m_View.buttonVisible);
|
||||
|
||||
m_Model.TriggerProjectStatusChanged(ProjectStatus.NoSeat);
|
||||
Assert.IsTrue(m_View.buttonVisible);
|
||||
|
||||
m_Model.TriggerProjectStatusChanged(ProjectStatus.Loading);
|
||||
Assert.IsFalse(m_View.buttonVisible);
|
||||
|
||||
m_Model.TriggerProjectStatusChanged(ProjectStatus.Offline);
|
||||
Assert.IsFalse(m_View.buttonVisible);
|
||||
|
||||
m_Model.TriggerProjectStatusChanged(ProjectStatus.Maintenance);
|
||||
Assert.IsFalse(m_View.buttonVisible);
|
||||
|
||||
m_Model.TriggerProjectStatusChanged(ProjectStatus.Ready);
|
||||
Assert.IsFalse(m_View.buttonVisible);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStateChange()
|
||||
{
|
||||
m_Presenter.Start();
|
||||
|
||||
m_Model.ProjectStatus = ProjectStatus.Bound;
|
||||
m_Model.TriggerStateChanged();
|
||||
|
||||
Assert.IsTrue(m_View.buttonVisible);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 485ab142ed644e479a8eb9a8137b8461
|
||||
timeCreated: 1576186961
|
|
@ -0,0 +1,94 @@
|
|||
using System.Collections.Generic;
|
||||
using Unity.Cloud.Collaborate.Models.Structures;
|
||||
using Unity.Cloud.Collaborate.Presenters;
|
||||
using Unity.Cloud.Collaborate.Views;
|
||||
|
||||
namespace Unity.Cloud.Collaborate.Tests.Presenters
|
||||
{
|
||||
internal class TestChangesView : IChangesView
|
||||
{
|
||||
public int SetBusyStatusCount;
|
||||
public bool? SetBusyStatusValue;
|
||||
|
||||
public int SetSearchQueryCount;
|
||||
public string SetSearchQueryValue;
|
||||
|
||||
public int SetRevisionSummaryCount;
|
||||
public string SetRevisionSummaryValue;
|
||||
|
||||
public int SetConflictsCount;
|
||||
public IReadOnlyList<IChangeEntryData> SetConflictsValue;
|
||||
|
||||
public int SetChangesCount;
|
||||
public IReadOnlyList<IChangeEntryData> SetChangesValue;
|
||||
|
||||
public int SetToggledCountCount;
|
||||
public int? SetToggledCountValue;
|
||||
|
||||
public int SetPublishEnabledCount;
|
||||
public bool? SetPublishEnabledValue;
|
||||
public string SetPublishEnabledReason;
|
||||
|
||||
public int DisplayDialogueCount;
|
||||
|
||||
public IChangesPresenter Presenter { get; set; }
|
||||
public void SetBusyStatus(bool busy)
|
||||
{
|
||||
SetBusyStatusCount++;
|
||||
SetBusyStatusValue = busy;
|
||||
}
|
||||
|
||||
public void SetSearchQuery(string query)
|
||||
{
|
||||
SetSearchQueryCount++;
|
||||
SetSearchQueryValue = query;
|
||||
}
|
||||
|
||||
public void SetRevisionSummary(string message)
|
||||
{
|
||||
SetRevisionSummaryCount++;
|
||||
SetRevisionSummaryValue = message;
|
||||
}
|
||||
|
||||
public void SetConflicts(IReadOnlyList<IChangeEntryData> list)
|
||||
{
|
||||
SetConflictsCount++;
|
||||
SetConflictsValue = list;
|
||||
}
|
||||
|
||||
public void SetChanges(IReadOnlyList<IChangeEntryData> list)
|
||||
{
|
||||
SetChangesCount++;
|
||||
SetChangesValue = list;
|
||||
}
|
||||
|
||||
public void SetToggledCount(int count)
|
||||
{
|
||||
SetToggledCountCount++;
|
||||
SetToggledCountValue = count;
|
||||
}
|
||||
|
||||
public void SetPublishEnabled(bool enabled, string reason = null)
|
||||
{
|
||||
SetPublishEnabledCount++;
|
||||
SetPublishEnabledValue = enabled;
|
||||
SetPublishEnabledReason = reason;
|
||||
}
|
||||
|
||||
public bool DisplayDialogue(string title, string message, string affirmative)
|
||||
{
|
||||
DisplayDialogueCount++;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool DisplayDialogue(string title, string message, string affirmative, string negative)
|
||||
{
|
||||
DisplayDialogueCount++;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetSelectedChanges()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Tests/Editor/Presenters/TestChangesView.cs.meta
generated
Normal file
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Tests/Editor/Presenters/TestChangesView.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 85a8810f7371b644186b2bbc0fb8bc17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,72 @@
|
|||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Unity.Cloud.Collaborate.Models.Structures;
|
||||
using Unity.Cloud.Collaborate.Presenters;
|
||||
using Unity.Cloud.Collaborate.Views;
|
||||
|
||||
namespace Unity.Cloud.Collaborate.Tests.Presenters
|
||||
{
|
||||
internal class TestHistoryView : IHistoryView
|
||||
{
|
||||
public IHistoryPresenter Presenter { get; set; }
|
||||
|
||||
public bool DialogueReturnValue = true;
|
||||
|
||||
public bool? BusyStatus;
|
||||
public int? Page;
|
||||
public int? MaxPage;
|
||||
[CanBeNull]
|
||||
public IHistoryEntry ReceivedEntry;
|
||||
[CanBeNull]
|
||||
public string DialogueTitle;
|
||||
[CanBeNull]
|
||||
public string DialogueMessage;
|
||||
[CanBeNull]
|
||||
public string DialogueAffirmative;
|
||||
[CanBeNull]
|
||||
public string DialogueNegative;
|
||||
[CanBeNull]
|
||||
public IReadOnlyList<IHistoryEntry> ReceivedList;
|
||||
|
||||
public void SetBusyStatus(bool busy)
|
||||
{
|
||||
BusyStatus = busy;
|
||||
}
|
||||
|
||||
public void SetHistoryList(IReadOnlyList<IHistoryEntry> list)
|
||||
{
|
||||
ReceivedList = list;
|
||||
ReceivedEntry = null;
|
||||
}
|
||||
|
||||
public void SetPage(int page, int max)
|
||||
{
|
||||
Page = page;
|
||||
MaxPage = max;
|
||||
}
|
||||
|
||||
public void SetSelection(IHistoryEntry entry)
|
||||
{
|
||||
ReceivedEntry = entry;
|
||||
ReceivedList = null;
|
||||
}
|
||||
|
||||
public bool DisplayDialogue(string title, string message, string affirmative)
|
||||
{
|
||||
DialogueTitle = title;
|
||||
DialogueMessage = message;
|
||||
DialogueAffirmative = affirmative;
|
||||
DialogueNegative = null;
|
||||
return DialogueReturnValue;
|
||||
}
|
||||
|
||||
public bool DisplayDialogue(string title, string message, string affirmative, string negative)
|
||||
{
|
||||
DialogueTitle = title;
|
||||
DialogueMessage = message;
|
||||
DialogueAffirmative = affirmative;
|
||||
DialogueNegative = negative;
|
||||
return DialogueReturnValue;
|
||||
}
|
||||
}
|
||||
}
|
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Tests/Editor/Presenters/TestHistoryView.cs.meta
generated
Normal file
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Tests/Editor/Presenters/TestHistoryView.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4d82f3cb1859dfe4fb3e5d83610c264c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using NUnit.Framework;
|
||||
using Unity.Cloud.Collaborate.Components;
|
||||
using Unity.Cloud.Collaborate.Presenters;
|
||||
using Unity.Cloud.Collaborate.Views;
|
||||
|
||||
namespace Unity.Cloud.Collaborate.Tests.Presenters
|
||||
{
|
||||
internal class TestMainView : IMainView
|
||||
{
|
||||
public int? tabIndex;
|
||||
|
||||
public bool inProgress;
|
||||
|
||||
public (string title, string details, int percentage, int completed, int total, bool isPercentage, bool canCancel)? progress;
|
||||
|
||||
[CanBeNull]
|
||||
public string backNavigation;
|
||||
|
||||
public IMainPresenter Presenter { get; set; }
|
||||
|
||||
public Dictionary<string, (string id, AlertBox.AlertLevel level, string message, (string text, Action action)? button)> alerts = new Dictionary<string, (string id, AlertBox.AlertLevel level, string message, (string text, Action action)? button)>();
|
||||
|
||||
public void AddAlert(string id, AlertBox.AlertLevel level, string message, (string text, Action action)? button = null)
|
||||
{
|
||||
alerts[id] = (id, level, message, button);
|
||||
}
|
||||
|
||||
public void RemoveAlert(string id)
|
||||
{
|
||||
alerts.Remove(id);
|
||||
}
|
||||
|
||||
public void SetTab(int index)
|
||||
{
|
||||
tabIndex = index;
|
||||
}
|
||||
|
||||
public void AddOperationProgress()
|
||||
{
|
||||
Assert.IsFalse(inProgress);
|
||||
inProgress = true;
|
||||
}
|
||||
|
||||
public void RemoveOperationProgress()
|
||||
{
|
||||
Assert.IsTrue(inProgress);
|
||||
inProgress = false;
|
||||
}
|
||||
|
||||
public void SetOperationProgress(string title, string details, int percentage, int completed, int total, bool isPercentage, bool canCancel)
|
||||
{
|
||||
progress = (title, details, percentage, completed, total, isPercentage, canCancel);
|
||||
}
|
||||
|
||||
public void ClearBackNavigation()
|
||||
{
|
||||
backNavigation = null;
|
||||
}
|
||||
|
||||
public void DisplayBackNavigation(string text)
|
||||
{
|
||||
backNavigation = text;
|
||||
}
|
||||
}
|
||||
}
|
3
Library/PackageCache/com.unity.collab-proxy@1.3.9/Tests/Editor/Presenters/TestMainView.cs.meta
generated
Normal file
3
Library/PackageCache/com.unity.collab-proxy@1.3.9/Tests/Editor/Presenters/TestMainView.cs.meta
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 63ffed391ffc4e11949711d888affd00
|
||||
timeCreated: 1576178951
|
|
@ -0,0 +1,21 @@
|
|||
using Unity.Cloud.Collaborate.Presenters;
|
||||
using Unity.Cloud.Collaborate.Views;
|
||||
|
||||
namespace Unity.Cloud.Collaborate.Tests.Presenters
|
||||
{
|
||||
internal class TestStartView : IStartView
|
||||
{
|
||||
public bool buttonVisible;
|
||||
|
||||
public IStartPresenter Presenter { get; set; }
|
||||
|
||||
public string Text { get; set; }
|
||||
|
||||
public string ButtonText { get; set; }
|
||||
|
||||
public void SetButtonVisible(bool isVisible)
|
||||
{
|
||||
buttonVisible = isVisible;
|
||||
}
|
||||
}
|
||||
}
|
3
Library/PackageCache/com.unity.collab-proxy@1.3.9/Tests/Editor/Presenters/TestStartView.cs.meta
generated
Normal file
3
Library/PackageCache/com.unity.collab-proxy@1.3.9/Tests/Editor/Presenters/TestStartView.cs.meta
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c26636c25de34fd1b5d32fd8fdb9b47d
|
||||
timeCreated: 1576186207
|
Loading…
Add table
Add a link
Reference in a new issue