Update IDataViewerCollection and IDataViewer
- Add support for `DataViewerCollection::IsViewerRegistered` - Update `DataViewerCollection::IsViewerEnabled`to correctly reflect the behavior - Add `IsTransmissionEnabled`to `IDataViewer` interface.
This commit is contained in:
Родитель
5ee30d8162
Коммит
15d2b4f230
|
@ -28,7 +28,7 @@ namespace ARIASDK_NS_BEGIN {
|
|||
|
||||
std::lock_guard<std::mutex> lock(m_dataViewerMapLock);
|
||||
|
||||
if (IsViewerInCollection(dataViewer->GetName()))
|
||||
if (GetViewerFromCollection_NotThreadSafe(dataViewer->GetName()) != nullptr)
|
||||
{
|
||||
std::stringstream errorMessage;
|
||||
errorMessage << "Viewer: '" << dataViewer->GetName() << "' is already registered";
|
||||
|
@ -68,6 +68,23 @@ namespace ARIASDK_NS_BEGIN {
|
|||
}
|
||||
|
||||
bool DataViewerCollection::IsViewerEnabled(const char* viewerName) const
|
||||
{
|
||||
auto viewerFetched = GetViewerFromCollection_ThreadSafe(viewerName);
|
||||
return viewerFetched != nullptr && viewerFetched->IsTransmissionEnabled();
|
||||
}
|
||||
|
||||
bool DataViewerCollection::IsViewerRegistered(const char* viewerName) const
|
||||
{
|
||||
return GetViewerFromCollection_ThreadSafe(viewerName) != nullptr;
|
||||
}
|
||||
|
||||
bool DataViewerCollection::AnyViewerRegistered() const noexcept
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_dataViewerMapLock);
|
||||
return !m_dataViewerCollection.empty();
|
||||
}
|
||||
|
||||
std::shared_ptr<IDataViewer> DataViewerCollection::GetViewerFromCollection_ThreadSafe(const char* viewerName) const
|
||||
{
|
||||
if (viewerName == nullptr)
|
||||
{
|
||||
|
@ -76,10 +93,10 @@ namespace ARIASDK_NS_BEGIN {
|
|||
|
||||
std::lock_guard<std::mutex> lock(m_dataViewerMapLock);
|
||||
|
||||
return IsViewerInCollection(viewerName);
|
||||
return GetViewerFromCollection_NotThreadSafe(viewerName);
|
||||
}
|
||||
|
||||
bool DataViewerCollection::IsViewerInCollection(const char* viewerName) const
|
||||
|
||||
std::shared_ptr<IDataViewer> DataViewerCollection::GetViewerFromCollection_NotThreadSafe(const char* viewerName) const
|
||||
{
|
||||
if (viewerName == nullptr)
|
||||
{
|
||||
|
@ -93,12 +110,18 @@ namespace ARIASDK_NS_BEGIN {
|
|||
return strcmp(viewer->GetName(), viewerName) == 0;
|
||||
});
|
||||
|
||||
return lookupResult != m_dataViewerCollection.end();
|
||||
if (lookupResult != m_dataViewerCollection.end())
|
||||
{
|
||||
return *lookupResult;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool DataViewerCollection::IsViewerEnabled() const noexcept
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_dataViewerMapLock);
|
||||
return !m_dataViewerCollection.empty();
|
||||
return !m_dataViewerCollection.empty() &&
|
||||
std::find_if(m_dataViewerCollection.begin(), m_dataViewerCollection.end(), [](std::shared_ptr<IDataViewer> viewer) { return viewer->IsTransmissionEnabled(); }) != m_dataViewerCollection.end();
|
||||
}
|
||||
} ARIASDK_NS_END
|
||||
|
|
|
@ -26,6 +26,10 @@ namespace ARIASDK_NS_BEGIN {
|
|||
|
||||
virtual bool IsViewerEnabled() const noexcept override;
|
||||
|
||||
virtual bool IsViewerRegistered(const char* viewerName) const override;
|
||||
|
||||
virtual bool AnyViewerRegistered() const noexcept override;
|
||||
|
||||
virtual ~DataViewerCollection() noexcept {};
|
||||
private:
|
||||
MATSDK_LOG_DECL_COMPONENT_CLASS();
|
||||
|
@ -33,7 +37,8 @@ namespace ARIASDK_NS_BEGIN {
|
|||
mutable std::mutex m_dataViewerMapLock;
|
||||
|
||||
protected:
|
||||
bool IsViewerInCollection(const char* viewerName) const;
|
||||
std::shared_ptr<IDataViewer> GetViewerFromCollection_ThreadSafe(const char* viewerName) const;
|
||||
std::shared_ptr<IDataViewer> GetViewerFromCollection_NotThreadSafe(const char* viewerName) const;
|
||||
std::vector<std::shared_ptr<IDataViewer>> m_dataViewerCollection;
|
||||
};
|
||||
|
||||
|
|
|
@ -27,6 +27,12 @@ namespace ARIASDK_NS_BEGIN
|
|||
/// Get the name of the current viewer.
|
||||
/// </summary>
|
||||
virtual const char* GetName() const noexcept = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Check if the current viewer is transmitting.
|
||||
/// </summary>
|
||||
/// <returns>True if transmission is enabled, false otherwise.</returns>
|
||||
virtual bool IsTransmissionEnabled() const noexcept = 0;
|
||||
};
|
||||
|
||||
} ARIASDK_NS_END
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace ARIASDK_NS_BEGIN
|
|||
virtual void UnregisterAllViewers() = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Check if the given viewer (name) is registered as a data viewer.
|
||||
/// Check if the given viewer (name) is registered as a data viewer and is actively transmitting.
|
||||
/// </summary>
|
||||
/// <param name="viewerName">
|
||||
/// Unique Name to identify the viewer being checked.
|
||||
|
@ -50,9 +50,22 @@ namespace ARIASDK_NS_BEGIN
|
|||
virtual bool IsViewerEnabled(const char* viewerName) const = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Check if any viewers are registered.
|
||||
/// Check if any viewers are registered and actively transmitting.
|
||||
/// </summary>
|
||||
virtual bool IsViewerEnabled() const noexcept = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Check if the given viewer (name) is registered as a data viewer.
|
||||
/// </summary>
|
||||
/// <param name="viewerName">
|
||||
/// Unique Name to identify the viewer being checked.
|
||||
/// </param>
|
||||
virtual bool IsViewerRegistered(const char* viewerName) const = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Check if any viewers are registered.
|
||||
/// </summary>
|
||||
virtual bool AnyViewerRegistered() const noexcept = 0;
|
||||
};
|
||||
|
||||
} ARIASDK_NS_END
|
||||
|
|
|
@ -146,6 +146,16 @@ namespace ARIASDK_NS_BEGIN
|
|||
return false;
|
||||
}
|
||||
|
||||
virtual bool IsViewerRegistered(const char* viewerName) const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool AnyViewerRegistered() const noexcept override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual ~NullDataViewerCollection() {};
|
||||
};
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#define MAT_VERSION_HPP
|
||||
// WARNING: DO NOT MODIFY THIS FILE!
|
||||
// This file has been automatically generated, manual changes will be lost.
|
||||
#define BUILD_VERSION_STR "3.3.140.1"
|
||||
#define BUILD_VERSION 3,3,140,1
|
||||
#define BUILD_VERSION_STR "3.3.170.1"
|
||||
#define BUILD_VERSION 3,3,170,1
|
||||
|
||||
#ifndef RESOURCE_COMPILER_INVOKED
|
||||
#include <stdint.h>
|
||||
|
@ -30,7 +30,7 @@ namespace ARIASDK_NS_BEGIN {
|
|||
uint64_t const Version =
|
||||
((uint64_t)3 << 48) |
|
||||
((uint64_t)3 << 32) |
|
||||
((uint64_t)140 << 16) |
|
||||
((uint64_t)170 << 16) |
|
||||
((uint64_t)1);
|
||||
|
||||
} ARIASDK_NS_END
|
||||
|
|
|
@ -11,11 +11,9 @@ using namespace MAT;
|
|||
class MockIDataViewer : public IDataViewer
|
||||
{
|
||||
public:
|
||||
MockIDataViewer()
|
||||
: MockIDataViewer("MockIDataViewer") {}
|
||||
|
||||
MockIDataViewer(const char* name)
|
||||
: m_name(name) {}
|
||||
|
||||
MockIDataViewer(const char* name, bool isTransmissionEnabled) :
|
||||
m_name(name), m_isTransmissionEnabled(isTransmissionEnabled) {}
|
||||
|
||||
void ReceiveData(const std::vector<uint8_t>& packetData) noexcept override
|
||||
{
|
||||
|
@ -27,8 +25,14 @@ public:
|
|||
return m_name;
|
||||
}
|
||||
|
||||
bool IsTransmissionEnabled() const noexcept override
|
||||
{
|
||||
return m_isTransmissionEnabled;
|
||||
}
|
||||
|
||||
mutable std::vector<uint8_t> localPacketData;
|
||||
const char* m_name;
|
||||
bool m_isTransmissionEnabled;
|
||||
};
|
||||
|
||||
class TestDataViewerCollection : public DataViewerCollection
|
||||
|
@ -40,6 +44,7 @@ public:
|
|||
using DataViewerCollection::UnregisterViewer;
|
||||
using DataViewerCollection::UnregisterAllViewers;
|
||||
using DataViewerCollection::IsViewerEnabled;
|
||||
using DataViewerCollection::IsViewerRegistered;
|
||||
|
||||
std::vector<std::shared_ptr<IDataViewer>>& GetCollection()
|
||||
{
|
||||
|
@ -55,25 +60,25 @@ TEST(DataViewerCollectionTests, RegisterViewer_DataViewerIsNullptr_ThrowsInvalid
|
|||
|
||||
TEST(DataViewerCollectionTests, RegisterViewer_DataViewerIsNotNullptr_NoExceptions)
|
||||
{
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>();
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>("MockViewer", /*isTransmissionEnabled*/ false);
|
||||
TestDataViewerCollection dataViewerCollection { };
|
||||
ASSERT_NO_THROW(dataViewerCollection.RegisterViewer(viewer));
|
||||
}
|
||||
|
||||
TEST(DataViewerCollectionTests, RegisterViewer_SharedDataViewerRegistered_SharedDataViewerRegisteredCorrectly)
|
||||
{
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>("sharedName");
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>("sharedName", /*isTransmissionEnabled*/ true);
|
||||
TestDataViewerCollection dataViewerCollection { };
|
||||
ASSERT_NO_THROW(dataViewerCollection.RegisterViewer(viewer));
|
||||
ASSERT_TRUE(dataViewerCollection.IsViewerEnabled(viewer->GetName()));
|
||||
ASSERT_TRUE(dataViewerCollection.IsViewerRegistered(viewer->GetName()));
|
||||
}
|
||||
|
||||
TEST(DataViewerCollectionTests, RegisterViewer_MultiplesharedDataViewersRegistered_sharedDataViewersRegisteredCorrectly)
|
||||
{
|
||||
std::shared_ptr<IDataViewer> viewer1 = std::make_shared<MockIDataViewer>("sharedName1");
|
||||
std::shared_ptr<IDataViewer> viewer2 = std::make_shared<MockIDataViewer>("sharedName2");
|
||||
std::shared_ptr<IDataViewer> viewer3 = std::make_shared<MockIDataViewer>("sharedName3");
|
||||
std::shared_ptr<IDataViewer> viewer4 = std::make_shared<MockIDataViewer>("sharedName4");
|
||||
std::shared_ptr<IDataViewer> viewer1 = std::make_shared<MockIDataViewer>("sharedName1", /*isTransmissionEnabled*/ false);
|
||||
std::shared_ptr<IDataViewer> viewer2 = std::make_shared<MockIDataViewer>("sharedName2", /*isTransmissionEnabled*/ false);
|
||||
std::shared_ptr<IDataViewer> viewer3 = std::make_shared<MockIDataViewer>("sharedName3", /*isTransmissionEnabled*/ false);
|
||||
std::shared_ptr<IDataViewer> viewer4 = std::make_shared<MockIDataViewer>("sharedName4", /*isTransmissionEnabled*/ false);
|
||||
TestDataViewerCollection dataViewerCollection { };
|
||||
|
||||
ASSERT_NO_THROW(dataViewerCollection.RegisterViewer(viewer1));
|
||||
|
@ -82,15 +87,15 @@ TEST(DataViewerCollectionTests, RegisterViewer_MultiplesharedDataViewersRegister
|
|||
ASSERT_NO_THROW(dataViewerCollection.RegisterViewer(viewer4));
|
||||
|
||||
ASSERT_EQ(dataViewerCollection.GetCollection().size(), size_t { 4 });
|
||||
ASSERT_TRUE(dataViewerCollection.IsViewerEnabled(viewer1->GetName()));
|
||||
ASSERT_TRUE(dataViewerCollection.IsViewerEnabled(viewer2->GetName()));
|
||||
ASSERT_TRUE(dataViewerCollection.IsViewerEnabled(viewer3->GetName()));
|
||||
ASSERT_TRUE(dataViewerCollection.IsViewerEnabled(viewer4->GetName()));
|
||||
ASSERT_TRUE(dataViewerCollection.IsViewerRegistered(viewer1->GetName()));
|
||||
ASSERT_TRUE(dataViewerCollection.IsViewerRegistered(viewer2->GetName()));
|
||||
ASSERT_TRUE(dataViewerCollection.IsViewerRegistered(viewer3->GetName()));
|
||||
ASSERT_TRUE(dataViewerCollection.IsViewerRegistered(viewer4->GetName()));
|
||||
}
|
||||
|
||||
TEST(DataViewerCollectionTests, RegisterViewer_DuplicateDataViewerRegistered_ThrowsInvalidArgumentException)
|
||||
{
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>("sharedName");
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>("sharedName", /*isTransmissionEnabled*/ false);
|
||||
TestDataViewerCollection dataViewerCollection { };
|
||||
ASSERT_NO_THROW(dataViewerCollection.RegisterViewer(viewer));
|
||||
|
||||
|
@ -100,7 +105,7 @@ TEST(DataViewerCollectionTests, RegisterViewer_DuplicateDataViewerRegistered_Thr
|
|||
// UnitTests(50918,0x10751a5c0) malloc: *** set a breakpoint in malloc_error_break to debug
|
||||
// /build/cpp_client_telemetry/tests/unittests/DataViewerCollectionTests.cpp:95: Failure
|
||||
// Expected: dataViewerCollection.RegisterViewer(otherViewer) throws an exception of type std::invalid_argument.
|
||||
std::shared_ptr<IDataViewer> otherViewer = std::make_shared<MockIDataViewer>("sharedName");
|
||||
std::shared_ptr<IDataViewer> otherViewer = std::make_shared<MockIDataViewer>("sharedName", /*isTransmissionEnabled*/ false);
|
||||
CheckForExceptionOrAbort<std::invalid_argument>([&dataViewerCollection, &otherViewer]() { dataViewerCollection.RegisterViewer(otherViewer); });
|
||||
}
|
||||
|
||||
|
@ -132,7 +137,7 @@ TEST(DataViewerCollectionTests, UnregisterViewer_ViewerNameIsNotRegistered_Throw
|
|||
|
||||
TEST(DataViewerCollectionTests, UnregisterViewer_ViewerNameIsRegistered_UnregistersCorrectly)
|
||||
{
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>("sharedName");
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>("sharedName", /*isTransmissionEnabled*/ false);
|
||||
TestDataViewerCollection dataViewerCollection { };
|
||||
dataViewerCollection.GetCollection().push_back(viewer);
|
||||
|
||||
|
@ -148,7 +153,7 @@ TEST(DataViewerCollectionTests, UnregisterAllViewers_NoViewersRegistered_Unregis
|
|||
|
||||
TEST(DataViewerCollectionTests, UnregisterAllViewers_OneViewerRegistered_UnregisterCallSuccessful)
|
||||
{
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>("sharedName");
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>("sharedName", /*isTransmissionEnabled*/ false);
|
||||
TestDataViewerCollection dataViewerCollection { };
|
||||
dataViewerCollection.GetCollection().push_back(viewer);
|
||||
|
||||
|
@ -158,9 +163,9 @@ TEST(DataViewerCollectionTests, UnregisterAllViewers_OneViewerRegistered_Unregis
|
|||
|
||||
TEST(DataViewerCollectionTests, UnregisterAllViewers_ThreeViewersRegistered_UnregisterCallSuccessful)
|
||||
{
|
||||
std::shared_ptr<IDataViewer> viewer1 = std::make_shared<MockIDataViewer>("sharedName1");
|
||||
std::shared_ptr<IDataViewer> viewer2 = std::make_shared<MockIDataViewer>("sharedName2");
|
||||
std::shared_ptr<IDataViewer> viewer3 = std::make_shared<MockIDataViewer>("sharedName3");
|
||||
std::shared_ptr<IDataViewer> viewer1 = std::make_shared<MockIDataViewer>("sharedName1", /*isTransmissionEnabled*/ false);
|
||||
std::shared_ptr<IDataViewer> viewer2 = std::make_shared<MockIDataViewer>("sharedName2", /*isTransmissionEnabled*/ false);
|
||||
std::shared_ptr<IDataViewer> viewer3 = std::make_shared<MockIDataViewer>("sharedName3", /*isTransmissionEnabled*/ false);
|
||||
TestDataViewerCollection dataViewerCollection { };
|
||||
dataViewerCollection.GetCollection().push_back(viewer1);
|
||||
dataViewerCollection.GetCollection().push_back(viewer2);
|
||||
|
@ -182,25 +187,46 @@ TEST(DataViewerCollectionTests, IsViewerEnabled_NoViewerIsRegistered_ReturnsFals
|
|||
ASSERT_FALSE(dataViewerCollection.IsViewerEnabled("sharedName"));
|
||||
}
|
||||
|
||||
TEST(DataViewerCollectionTests, IsViewerEnabled_SingleViewerIsRegistered_ReturnsTrueCorrectly)
|
||||
TEST(DataViewerCollectionTests, IsViewerEnabled_SingleViewerIsRegisteredAndNotTransmitting_ReturnsFalseCorrectly)
|
||||
{
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>("sharedName");
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>("sharedName", /*isTransmissionEnabled*/ false);
|
||||
TestDataViewerCollection dataViewerCollection { };
|
||||
dataViewerCollection.GetCollection().push_back(viewer);
|
||||
ASSERT_FALSE(dataViewerCollection.IsViewerEnabled(viewer->GetName()));
|
||||
}
|
||||
|
||||
TEST(DataViewerCollectionTests, IsViewerEnabled_SingleViewerIsRegisteredAndIsTransmitting_ReturnsTrueCorrectly)
|
||||
{
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>("sharedName", /*isTransmissionEnabled*/ true);
|
||||
TestDataViewerCollection dataViewerCollection { };
|
||||
dataViewerCollection.GetCollection().push_back(viewer);
|
||||
ASSERT_TRUE(dataViewerCollection.IsViewerEnabled(viewer->GetName()));
|
||||
}
|
||||
|
||||
TEST(DataViewerCollectionTests, IsViewerEnabled_MultipleViewersRegistered_ReturnsTrueCorrectly)
|
||||
TEST(DataViewerCollectionTests, IsViewerEnabled_MultipleViewersRegisteredAndNoneTransmitting_ReturnsFalseCorrectly)
|
||||
{
|
||||
std::shared_ptr<IDataViewer> viewer1 = std::make_shared<MockIDataViewer>("sharedName1");
|
||||
std::shared_ptr<IDataViewer> viewer2 = std::make_shared<MockIDataViewer>("sharedName2");
|
||||
std::shared_ptr<IDataViewer> viewer3 = std::make_shared<MockIDataViewer>("sharedName3");
|
||||
std::shared_ptr<IDataViewer> viewer1 = std::make_shared<MockIDataViewer>("sharedName1", /*isTransmissionEnabled*/ false);
|
||||
std::shared_ptr<IDataViewer> viewer2 = std::make_shared<MockIDataViewer>("sharedName2", /*isTransmissionEnabled*/ false);
|
||||
std::shared_ptr<IDataViewer> viewer3 = std::make_shared<MockIDataViewer>("sharedName3", /*isTransmissionEnabled*/ false);
|
||||
TestDataViewerCollection dataViewerCollection { };
|
||||
dataViewerCollection.GetCollection().push_back(viewer1);
|
||||
dataViewerCollection.GetCollection().push_back(viewer2);
|
||||
dataViewerCollection.GetCollection().push_back(viewer3);
|
||||
|
||||
ASSERT_TRUE(dataViewerCollection.IsViewerEnabled("sharedName3"));
|
||||
ASSERT_FALSE(dataViewerCollection.IsViewerEnabled("sharedName3"));
|
||||
}
|
||||
|
||||
TEST(DataViewerCollectionTests, IsViewerEnabled_MultipleViewersRegisteredAndOneTransmitting_ReturnsTrueCorrectly)
|
||||
{
|
||||
std::shared_ptr<IDataViewer> viewer1 = std::make_shared<MockIDataViewer>("sharedName1", /*isTransmissionEnabled*/ true);
|
||||
std::shared_ptr<IDataViewer> viewer2 = std::make_shared<MockIDataViewer>("sharedName2", /*isTransmissionEnabled*/ false);
|
||||
std::shared_ptr<IDataViewer> viewer3 = std::make_shared<MockIDataViewer>("sharedName3", /*isTransmissionEnabled*/ false);
|
||||
TestDataViewerCollection dataViewerCollection { };
|
||||
dataViewerCollection.GetCollection().push_back(viewer1);
|
||||
dataViewerCollection.GetCollection().push_back(viewer2);
|
||||
dataViewerCollection.GetCollection().push_back(viewer3);
|
||||
|
||||
ASSERT_TRUE(dataViewerCollection.IsViewerEnabled("sharedName1"));
|
||||
}
|
||||
|
||||
TEST(DataViewerCollectionTests, IsViewerEnabledNoParam_NoViewerIsRegistered_ReturnsFalseCorrectly)
|
||||
|
@ -209,19 +235,39 @@ TEST(DataViewerCollectionTests, IsViewerEnabledNoParam_NoViewerIsRegistered_Retu
|
|||
ASSERT_FALSE(dataViewerCollection.IsViewerEnabled());
|
||||
}
|
||||
|
||||
TEST(DataViewerCollectionTests, IsViewerEnabledNoParam_SingleViewerIsRegistered_ReturnsTrueCorrectly)
|
||||
TEST(DataViewerCollectionTests, IsViewerEnabledNoParam_SingleViewerIsRegisteredAndNotTransmitting_ReturnsFalseCorrectly)
|
||||
{
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>("sharedName");
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>("sharedName", /*isTransmissionEnabled*/ false);
|
||||
TestDataViewerCollection dataViewerCollection { };
|
||||
dataViewerCollection.GetCollection().push_back(viewer);
|
||||
ASSERT_FALSE(dataViewerCollection.IsViewerEnabled());
|
||||
}
|
||||
|
||||
TEST(DataViewerCollectionTests, IsViewerEnabledNoParam_SingleViewerIsRegisteredAndIsTransmitting_ReturnsTrueCorrectly)
|
||||
{
|
||||
std::shared_ptr<IDataViewer> viewer = std::make_shared<MockIDataViewer>("sharedName", /*isTransmissionEnabled*/ true);
|
||||
TestDataViewerCollection dataViewerCollection { };
|
||||
dataViewerCollection.GetCollection().push_back(viewer);
|
||||
ASSERT_TRUE(dataViewerCollection.IsViewerEnabled());
|
||||
}
|
||||
|
||||
TEST(DataViewerCollectionTests, IsViewerEnabledNoParam_MultipleViewersRegistered_ReturnsTrueCorrectly)
|
||||
TEST(DataViewerCollectionTests, IsViewerEnabledNoParam_MultipleViewersRegisteredAndOneTransmitting_ReturnsTrueCorrectly)
|
||||
{
|
||||
std::shared_ptr<IDataViewer> viewer1 = std::make_shared<MockIDataViewer>("sharedName1");
|
||||
std::shared_ptr<IDataViewer> viewer2 = std::make_shared<MockIDataViewer>("sharedName2");
|
||||
std::shared_ptr<IDataViewer> viewer3 = std::make_shared<MockIDataViewer>("sharedName3");
|
||||
std::shared_ptr<IDataViewer> viewer1 = std::make_shared<MockIDataViewer>("sharedName1", /*isTransmissionEnabled*/ false);
|
||||
std::shared_ptr<IDataViewer> viewer2 = std::make_shared<MockIDataViewer>("sharedName2", /*isTransmissionEnabled*/ true);
|
||||
std::shared_ptr<IDataViewer> viewer3 = std::make_shared<MockIDataViewer>("sharedName3", /*isTransmissionEnabled*/ false);
|
||||
TestDataViewerCollection dataViewerCollection { };
|
||||
dataViewerCollection.GetCollection().push_back(viewer1);
|
||||
dataViewerCollection.GetCollection().push_back(viewer2);
|
||||
dataViewerCollection.GetCollection().push_back(viewer3);
|
||||
ASSERT_TRUE(dataViewerCollection.IsViewerEnabled());
|
||||
}
|
||||
|
||||
TEST(DataViewerCollectionTests, IsViewerEnabledNoParam_MultipleViewersRegisteredAndAllTransmitting_ReturnsTrueCorrectly)
|
||||
{
|
||||
std::shared_ptr<IDataViewer> viewer1 = std::make_shared<MockIDataViewer>("sharedName1", /*isTransmissionEnabled*/ true);
|
||||
std::shared_ptr<IDataViewer> viewer2 = std::make_shared<MockIDataViewer>("sharedName2", /*isTransmissionEnabled*/ true);
|
||||
std::shared_ptr<IDataViewer> viewer3 = std::make_shared<MockIDataViewer>("sharedName3", /*isTransmissionEnabled*/ true);
|
||||
TestDataViewerCollection dataViewerCollection { };
|
||||
dataViewerCollection.GetCollection().push_back(viewer1);
|
||||
dataViewerCollection.GetCollection().push_back(viewer2);
|
||||
|
|
|
@ -119,16 +119,18 @@ TEST(DefaultDataViewerTests, EnableRemoteViewer_ValidEndpoint_TransmissionEnable
|
|||
};
|
||||
|
||||
MockDefaultDataViewer viewer(mockHttpClient, "Test");
|
||||
viewer.EnableRemoteViewer("TestEndpoint");
|
||||
viewer.EnableRemoteViewer("http://TestEndpoint");
|
||||
|
||||
ASSERT_TRUE(viewer.IsTransmissionEnabled());
|
||||
}
|
||||
|
||||
TEST(DefaultDataViewerTests, EnableRemoteViewer_NullOrEmptryEndpoint_ThrowsInvalidArgument)
|
||||
TEST(DefaultDataViewerTests, EnableRemoteViewer_InvalidEndpoint_ThrowsInvalidArgument)
|
||||
{
|
||||
MockDefaultDataViewer viewer(mockHttpClient, "Test");
|
||||
CheckForExceptionOrAbort<std::invalid_argument>([&viewer]() { viewer.EnableRemoteViewer(""); });
|
||||
CheckForExceptionOrAbort<std::invalid_argument>([&viewer]() { viewer.EnableRemoteViewer(" "); });
|
||||
CheckForExceptionOrAbort<std::invalid_argument>([&viewer]() { viewer.EnableRemoteViewer("TestEndpoint"); });
|
||||
CheckForExceptionOrAbort<std::invalid_argument>([&viewer]() { viewer.EnableRemoteViewer("https://TestEndpoint"); });
|
||||
}
|
||||
|
||||
TEST(DefaultDataViewerTests, EnableRemoteViewer_InvalidEndpoint_TransmissionNotEnabled)
|
||||
|
@ -143,7 +145,7 @@ TEST(DefaultDataViewerTests, EnableRemoteViewer_InvalidEndpoint_TransmissionNotE
|
|||
};
|
||||
|
||||
MockDefaultDataViewer viewer(mockHttpClient, "Test");
|
||||
viewer.EnableRemoteViewer("TestEndpoint");
|
||||
viewer.EnableRemoteViewer("http://TestEndpoint");
|
||||
|
||||
ASSERT_FALSE(viewer.IsTransmissionEnabled());
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче