-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding tests for IBindable and IDictionary
- Loading branch information
1 parent
892817e
commit a36c61e
Showing
5 changed files
with
207 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#include "pch.h" | ||
#include "ManualProjectionTestClasses.h" | ||
#include "IBindableIteratorTest.g.cpp" | ||
#include "IDictionaryTest.g.cpp" | ||
|
||
namespace winrt | ||
{ | ||
template <typename T, typename Allocator = std::allocator<T>> | ||
Windows::Foundation::Collections::IVectorView<T> single_threaded_vector_view(std::vector<T, Allocator>&& values = {}) | ||
{ | ||
return make<impl::input_vector_view<T, std::vector<T, Allocator>>>(std::move(values)); | ||
} | ||
|
||
template <typename K, typename V, typename Allocator = std::allocator<K>> | ||
Windows::Foundation::Collections::IMapView<K, V> single_threaded_map_view(std::map<K, V, Allocator>&& values = {}) | ||
{ | ||
return make<impl::input_map_view<K, V, std::map<K, V, Allocator>>>(std::move(values)); | ||
} | ||
} | ||
|
||
namespace winrt::TestComponentCSharp::implementation | ||
{ | ||
IBindableIteratorTest::IBindableIteratorTest() | ||
{ | ||
|
||
} | ||
|
||
bool IBindableIteratorTest::MoveNext() | ||
{ | ||
return true; | ||
} | ||
|
||
Windows::Foundation::IInspectable IBindableIteratorTest::Current() | ||
{ | ||
return Windows::Foundation::PropertyValue::CreateInt32(27861); | ||
} | ||
|
||
bool IBindableIteratorTest::HasCurrent() | ||
{ | ||
return true; | ||
} | ||
IDictionaryTest::IDictionaryTest() | ||
{ | ||
} | ||
hstring IDictionaryTest::Lookup(hstring key) | ||
{ | ||
return _map.Lookup(key); | ||
} | ||
bool IDictionaryTest::HasKey(hstring key) | ||
{ | ||
return _map.HasKey(key); | ||
} | ||
Windows::Foundation::Collections::IMapView<hstring, hstring> IDictionaryTest::GetView() | ||
{ | ||
return _map.GetView(); | ||
} | ||
bool IDictionaryTest::Insert(hstring key, hstring value) | ||
{ | ||
return _map.Insert(key, value); | ||
} | ||
void IDictionaryTest::Remove(hstring key) | ||
{ | ||
_map.Remove(key); | ||
} | ||
void IDictionaryTest::Clear() | ||
{ | ||
_map.Clear(); | ||
} | ||
int IDictionaryTest::Size() | ||
{ | ||
return _map.Size(); | ||
} | ||
|
||
Windows::Foundation::Collections::IIterator<Windows::Foundation::Collections::IKeyValuePair<hstring, hstring>> IDictionaryTest::First() | ||
{ | ||
return _map.First(); | ||
} | ||
|
||
bool IDictionaryTest::Consume(Windows::Foundation::Collections::IMap<hstring, hstring> map) | ||
{ | ||
map.Clear(); | ||
|
||
map.Insert(L"key.cpp", L"value.cpp"); | ||
if (map.Size() != 1) | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
#include "IBindableIteratorTest.g.h" | ||
#include "IDictionaryTest.g.h" | ||
|
||
namespace winrt::TestComponentCSharp::implementation | ||
{ | ||
struct IBindableIteratorTest : IBindableIteratorTestT<IBindableIteratorTest> | ||
{ | ||
IBindableIteratorTest(); | ||
bool MoveNext(); | ||
Windows::Foundation::IInspectable Current(); | ||
bool HasCurrent(); | ||
}; | ||
|
||
struct IDictionaryTest : IDictionaryTestT<IDictionaryTest> | ||
{ | ||
private: | ||
Windows::Foundation::Collections::IMap<hstring, hstring> _map{ | ||
winrt::single_threaded_map<hstring, hstring>() | ||
}; | ||
public: | ||
IDictionaryTest(); | ||
hstring Lookup(hstring key); | ||
bool HasKey(hstring key); | ||
Windows::Foundation::Collections::IMapView<hstring, hstring> GetView(); | ||
bool Insert(hstring key, hstring value); | ||
void Remove(hstring key); | ||
void Clear(); | ||
int Size(); | ||
Windows::Foundation::Collections::IIterator<Windows::Foundation::Collections::IKeyValuePair<hstring, hstring>> First(); | ||
|
||
static bool Consume(Windows::Foundation::Collections::IMap<hstring, hstring> map); | ||
}; | ||
} | ||
|
||
namespace winrt::TestComponentCSharp::factory_implementation | ||
{ | ||
struct IBindableIteratorTest : IBindableIteratorTestT<IBindableIteratorTest, implementation::IBindableIteratorTest, Windows::Foundation::IStringable> | ||
{ | ||
hstring ToString() | ||
{ | ||
return L"IBindableIteratorTest"; | ||
} | ||
}; | ||
|
||
struct IDictionaryTest : IDictionaryTestT<IDictionaryTest, implementation::IDictionaryTest, Windows::Foundation::IStringable> | ||
{ | ||
hstring ToString() | ||
{ | ||
return L"IDictionaryTest"; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters